Statalist The Stata Listserver


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

st: RE: RE: Data Manipulation--is the merge command appropriate?


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Data Manipulation--is the merge command appropriate?
Date   Mon, 25 Sep 2006 18:04:14 +0200

Elizabeth:
You can ensure that only "no foreign aid" missing values are recoded to 
zero (and all real missing values remain missing) by replacing the line 
-recode foreignaid .=0- with -recode foreignaid .=0 if _merge == 1-.
Furthermore, -set obs 4- should have been -set obs 5- (there are five 
years between 1990 and 1994).
HTH,
Maarten

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

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

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

*----------- begin new example -------------
clear
tempfile data countries
input Countryid year foreignaid
1 1993 230
1 1994 130
2 1990 100
2 1994 120      
end
sort Countryid year
save `data', replace

clear
set obs 2
gen Countryid = _n
save `countries', replace

clear
set obs 5
gen year = 1989 + _n 
cross using `countries'

sort Countryid year

merge Countryid year using `data'
sort Countryid year
recode foreignaid .=0 if _merge ==1
/*be careful that all . are due to no aid and not real missing values*/

list
*--------------- end new example -----------------



*
*   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