Hi all!
So I am a bit stuck on something I have to do.
1. I have a dataset which is multi level, and includes several individual observations for different countries (total 40), for different years/waves. (So for each year, there are 40 countries each having several individual observations of its own). So this is an individual level file.
2. In another dataset, I have the country level variables for all these countries and many more, which has variables like gdp of the country in that particular year
3. I have created an id variable - such that (country-wave) which is the same in both the files.
SO if the code is 47, it represents for country 4 in wave 7.
I want to import the gdp values for each country-wave variable from dataset in 2. such that it gets inputed into all the individual level observations corresponding to that particular (country-wave) variable.
All i need is a loop code such that it would take the gdp value corresponding to the country-wave number (e.g. 47) and put it into the individual file for observations that also correspond to the same country-wave number.
These are two different stata files.
Please help if you can! Will be very well appreciated.
Related Posts with Looping in Stata to extract values from one file to another
looping over data filesHello Users, I have data of banks by id numbers. What I want to do is: (1) to merge 4 tables of one …
ARIMA Modelling with Binary Independent VariableI am trying to fit an ARIMA model to my intervention analysis but when I use the syntax and add both…
regression panel data: OLS / GEEhello! I have a panel dataset on which I would like to perform a regression. my dependent variable …
inquire about rowtotal Code: gen s1 = x1+x2+x3+x4 replace s1 = 0 if s1 == . egen s2 = rowtotal(x*) assert s1==s2 Why it's …
Continuous interaction termI am working on understanding youth unemployment and use four main independent variables in my analy…
Subscribe to:
Post Comments (Atom)
0 Response to Looping in Stata to extract values from one file to another
Post a Comment