I must analyze the SOEP data files using stata. The name of data file is pgen.dta. There are prefixes a, b, c ,d …z for year from 1984 to 2009 and ba, bb, bc, bd for year 2010, 2011, 2012 and 2013 respectively. In these files, there are also same characters in variable names indicating survey year like aberwzeit, bberwzeit… There are also postfixes in certain variable names using last 2 digit number of survey year such as nation84 designating survey year 1984.
I must also analyze pequiv.dta which also named like pgen.dta
I must make these file (total 60 files) into just one file to make the panel data file. First of all I want to make pgen.dta files into pgen1.dta files keeping only interesting observations and fields.
For this job, I made the following ado file.
==============================
capture program drop preex1
program define preex1
local fileprefix a b c d e f g h I j k l m n o p q r s t u v w x y z //
ba bb bc bd
foreach v of local fileprefix {
use `v'pgen, clear
keep if (nation?? ==1) //if "`v'"=a then ??=84 else if "`v'"=b then ??=85 …..
keep if (emplst?? == 1 | emplst?? ==2)
keep persnr emplst?? expft?? expue?? “`v’”+erwzeit betr?? nace?? “`v’”+vebzeit nation?? “`v’”+bilzeit labgro??
save `v’pgen1.dta, replace
}
exit
===============
please comment for me for above underlined line!
I must also analyze pequiv.dta which also named like pgen.dta
I must make these file (total 60 files) into just one file to make the panel data file. First of all I want to make pgen.dta files into pgen1.dta files keeping only interesting observations and fields.
For this job, I made the following ado file.
==============================
capture program drop preex1
program define preex1
local fileprefix a b c d e f g h I j k l m n o p q r s t u v w x y z //
ba bb bc bd
foreach v of local fileprefix {
use `v'pgen, clear
keep if (nation?? ==1) //if "`v'"=a then ??=84 else if "`v'"=b then ??=85 …..
keep if (emplst?? == 1 | emplst?? ==2)
keep persnr emplst?? expft?? expue?? “`v’”+erwzeit betr?? nace?? “`v’”+vebzeit nation?? “`v’”+bilzeit labgro??
save `v’pgen1.dta, replace
}
exit
===============
please comment for me for above underlined line!
Comment