0
我有51個文件(我從所有50個州加上失業率加上BLS的DC),我需要將它們堆疊在一起。我正在研究一個將導入這些文件並將它們堆疊起來的宏,但是我堅持如何編寫一個循環來堆疊它們。我只是堆疊第一個和最後一個數據集,而沒有介於兩者之間。我不知道我做錯了什麼,任何幫助將不勝感激。提前致謝。堆棧數據循環 - SAS宏
/*MACRO TO IMPORT TRANSLATED RAW DATA FILES*/
%macro import;
%do iterate = 1 %to &files;
data _null_;
set files(where = (file = &iterate));
call symput('infile',left(trim(filename)));
call symput('State',left(trim(state)));
run;
%put &infile;
%put &state;
/*IMPORT RAW DATAFILES*/
proc import datafile = "&raw\&infile" out = &State dbms = xls replace;
getnames = yes; namerow = 11; datarow = 12;
run;
/*CREATE A NEW STATE COLUMN*/
data &State;
set &State;
State = "&State";
run;
%if &iterate = 1 %then %do;
data merge1;
keep year period labor_force employment unemployment unemployment_rate state;
format year 4. period $3. labor_force employment unemployment comma12.2 unemployment_rate 4.2
state $24.;
set &state;
run;
%end;
%if &iterate > 1 %then %do;
data unemploy_merge;
keep year period labor_force employment unemployment unemployment_rate state;
set merge1 &state;
run;
%end;
%end;
%mend import;