Is it possible to use the foreach function for part of the name of a file or
part of a variable name?
I would like to write something similar to what below (in which there is
something wrong, but I do not know if it is only a matter of quotes or so or
it is not possible to do what I want to do), where the x indicates the wave
so that the file has the same name just differing in the wave they were
collected, as well as the variable sin the files, they are the same but they
are preceeded by a letter indicating the wave.
foreach x in a b c d e f g h u j k l m n o p q r s t u {
use "D:\Project\Data_anal\GSOEP\CD1984-2004\"`x'"kind.dta"
sort persnr
save "D:\Project\Data_anal\GSOEP\CD1984-2004\"`x'"kind.dta", replace
use "D:\Project\Data_anal\GSOEP\My analyses\temp\"`x'"p_mar.dta"
sort persnr
merge using "D:\Project\Data_anal\GSOEP\CD1984-2004\"`x'"kind.dta", keep
("`x'"kzahl "`x'"hhgr)
drop _merge
save "D:\Project\Data_anal\GSOEP\My analyses\temp\"`x'"p_mar.dta", replace
}
*
* 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/