Your expanding your question when you don't have your first one complete....one step at a time.
Here's a method that will work, you should fix the filename list to be reflective of your file names. But it works without macros and is easier to understand and read. It's untested so there's probably errors, but it should be relatively easy to debug.
The data step creates a file list with the list of file names.
The second data step reads all the files into one dataset, with a variable that identifies the source.
data file_list;
do i=1 to 16;
do j=1 to 2;
if i=16 and j=2 then
file_name=catt("\\lhs4\prerelease\ANALYSIS\DATA\TABS\20", put(i, z2.),
"\tabmonth", j, ".prn");
else
filename=catt("\\fld8filer\Tabs\tabmonth", j, put(i, z2.), ".prn");
output;
end;
end;
run;
filename placehold;
data want;
set file_list;
infile placehold filevar=file_name filename=filename eov=eov lrecl=430
missover;
input @;
if _n_ eq 1 or eov then
do;
txt_file_name=scan(filename, -1, "\");
eov=0;
end;
else
input
@6 PROV 2. /* PROV */
@29 SYEAR 4. /* Year */
@33 SMNTH 2. /* Month */
@29 SDATE
6. /* Survey year and month - yyyymm */
@122
SEX $CHAR1. /* Sex of respondent. */
@140 NAICS
2. /* Industry 2-digit */
@140 NAICS4
4. /* Industry 4-digit */
@144
SOC4 $CHAR4. /* occupation 4-digit */;
if missing(AGE_TABS) then
AGEGROUP_main=.;
else if AGE_TABS LT 15 then
AGEGROUP_main=1;
/* LT 15 */
else if 15 LE AGE_TABS LT 25 then
AGEGROUP_main=2;
/*15-24 */
else if 25 LE AGE_TABS LT 55 then
AGEGROUP_main=3;
/* 25-54 */
else
AGEGROUP_main=4;
/* 55+ */
run;
... View more