我有以下do
文件:
/* 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.
我有每月的数据,我可以运行这个程序来dta
为每年的每个月创建文件。
但是,我每个月和每年都有几个原始数据。例如,我可以为 2010 年到2012 年的, , , ... 运行此do
文件。我要为每个月获取一个文件,我必须在每次需要时更改它以用于不同的月份。Jan
Feb
March
April
April
dta
我想知道如何通过某种宏来实现这一点?
某种代码在代码周围添加循环,引用与该文件对应的每月文件的do
文件名。