-1

次の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, ... で実行できます。月ごとにファイルを取得するには、別の月にファイルが必要になるたびに変更する必要があります。AprilAprildta

ある種のマクロを介してこれを達成する方法を知りたいですか?

そのファイルに対応する月次ファイルのファイル名を参照するコードの周りにループを追加する何らかのコードdo

4

1 に答える 1