Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Data management in Stata 9.0


From   Maarten buis <[email protected]>
To   stata list <[email protected]>
Subject   st: RE: Data management in Stata 9.0
Date   Tue, 6 May 2008 17:42:08 +0100 (BST)

--- Ramaele Moshoeshoe wrote me privately:
> I am writing an MA in Economics thesis at the University of
> Nairobi�and i am�using household budget suvery data. The problem with
> my data is that it is mixed up, i.e. it has both household-level
> information and each household member's information. Households
> numbers are also not unique.�It appears as follows;
> Zone���District��� HH no.��� Region
> 1��� ��� ��� 01��� ��� ��� 1����������� 2
> 1��� ��� ��� 02������������1����������� 2
> 1����������� 02��� ��� ��� 2��� ��� ��� 2
> 1��� ��� ��� 02��� ��� ��� 1��� ��� ��� 1
> That is, for each household leaving in a given�Zone and Region of any
> given District, there is a number that is unique within that Zone and
> Region only but shared by many other households in other Regions and
> Zones and/or in other Districts.
> My problem is now to give each household a unique I.D. for the entire
> data set such that for all households and/or individuals sharing the
> same number fall under one Household, taking into accout the Zone and
> Region.

First of all look at point 5 of the statalist FAQ:
http://www.stata.com/support/faqs/res/statalist.html

You can create your unique id in the following way: 

*--------------- begin example ----------------
drop _all
input zone district hhno region
1 01 1 2
1 02 1 2
1 02 2 2
1 02 1 1
end

gen long id = hhno + 10*zone + 100*district + 1000*region
list
exit
*---------------- end example -------------------

You should take some care about the number of digits in each variable,
so if zone has values with two digits you should multiply zone with
100, district with 1000, and region with 10000. 

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index