x cd /pub/data/stf903/Tools; %let pgm=cnvt9782; filename pgm "&pgm..sas"; /* ------Convert the raw stf3, 1990 file for one or more states to SAS dataset (2 - an I and an H set). Input files are in fixed lrecl format as stored in study # 9782, icpsr collection. This setup being coded May 13, 2003. Borrowing from earlier cnvtnj.sas setup, and using the same stf903c conversion macro that we have been using for over 10 years to convert these files. John Blodgett, OSEDA, U. of Missouri Outreach & Extension under a contract with the Missouri Census Data Center. ------*/ options compress=yes; libname stf903 '/pub/data/stf903'; title "&pgm: Convert 1990 STF903 Files"; *filename maclib '/pub/sas/macros'; *<---the stf903c macro will include module attr903.sas out of this directory--; filename samplein 'sample_in.dat'; *--define the "exit macro" used to pre-filter any "H'(ierarchal) level summaries - we process those separately in next step--; %macro filterh; _keep=0; drop _keep; *--in the stf903c macro we specify "end=lastrec" on infile; do until(_keep ); if lastrec then stop; input slvl $11-13 @; if slvl in ('070','080','090') then do; _keep=0; input; *--release rec; end; else _keep=1; *--leave loop and get on with reading rec; end; %mend filterh; *--And now the companion macro that filters the inventory levels--; %macro filteri; _keep=0; drop _keep; do until(_keep ); if lastrec then stop; input slvl $11-13 @; if not (slvl in ('070','080','090')) then do; _keep=0; input; *--release rec; end; else _keep=1; *--leave loop and get on with reading rec; end; %mend filteri; %macro doit(state,stab); ***filename in pipe "gunzip -cd /pub/data/stf903/rawfiles/da9782.&stab.&state._data_lrec.gz"; ***icpsr changed their naming conventions and things are a bit clumsier than before---; *************Change 5038028 to the number assigned to the download request from ICPSR each time***************; filename in pipe "unzip -p /pub/data/stf903/rawfiles/icpsr9782.zip 5038028/ICPSR_09782/DS00&state._Part_&state._&statenm/09782-00&state.-Data.txt"; *--invoke the conversion macro for the Inventory summaries-; %stf903c(setout=stf903.&stab.i, prefiltr=filterh, attribs=1, cnvtmls=0) run; *---------------now do the H summaries-----------------------*; *--invoke the conversion macro for the Hierarchal summaries-; %stf903c(setout=stf903.&stab.h, prefiltr=filteri, labels=1, cnvtmls=0) run; *proc sql; * create view stf903.&stab.sl090 as * select * from &stab.h where slvl='090'; * quit; proc datasets library=stf903 nolist; modify &stab.i; index create slvl; index create county; modify &stab.h; index create slvl; index create county; quit; filename in clear; %mend doit; *---the dostates macro will invoke doit for each state specified--; %*dostates(01 02 04 05) ; options NOmprint; %*dostates(17 20 29,names=1); %dostates(20,names=1);