I have the following do
file:
/* The following line should contain
the complete path and name of the raw data file.
On a PC, use backslashes in paths as in C:\ */
local dat_name "/homes/data/cps-basic/jan10pub.dat"
/* The following line should contain the path to your output '.dta' file */
local dta_name "cpsb2010_1.dta"
/* The following line should contain the path to the data dictionary file */
local dct_name "cpsbjan10.dct"
/* The line below does NOT need to be changed */
quietly infile using "`dct_name'", using("`dat_name'") clear
/*------------------------------------------------
All items, except those with one character, also can have values
of -1, -2, or -3 even if the values are not in the documentation
The meaning is
-1 .Blank or not in universe
-2 .Don't know
-3 .Refused
The following changes in variable names have been made, if necessary:
'$' to 'd'; '-' to '_'; '%' to 'p';
($ = unedited data; - = edited data; % = allocated data)
Decimal places have been made explict in the dictionary file.
Stata resolves a missing value of -1 / # of decimal places as a missing
-----------------------------------------------*/
** These note statements incorporate variable universes into the Stata data
note: by Jean Roth, jroth@nber.org Mon Feb 28 13:28:35 EST 2011
note hrmonth: U ALL HHLD's IN SAMPLE
note hryear4: U ALL HHLDs IN SAMPLE
note hurespli: U ALL HHLDs IN SAMPLE
note hufinal: U ALL HHLDs IN SAMPLE
note huspnish: U ALL HHLDs IN SAMPLE
note hetenure: U ALL HHLDs IN SAMPLE
note hehousut: U HRINTSTA = 1 OR HUTYPB = 1-3
note hetelhhd: U ALL HHLDs IN SAMPLE
note hetelavl: U HRINTSTA = 1
.... and so on.
I have monthly data and I can run this program to create the dta
file for each month of year.
However, I have several raw data for each month and year. For example, I can run this do
file for Jan
, Feb
, March
, April
... for the year 2010 until April
2012. For me to get a dta
file for each month, I have to go and change it every time I want it for a different month.
I would like to know how one can accomplish this via some sort of a macro?
Some sort of code to add loops around the code referring to the filenames of the monthly files corresponding to that do
file.