x cd /pub/data/stf904/Tools; %let pgm=cnvt_usfiles; filename pgm "&pgm..sas"; *---Convert the 1990 STF4, File C datasets for total pop, A and B tables, and for selected B tables files. JGB, 12/2005. Edited "wht" to "whi" but did not resubmit. Manually renamed the datasets. 12/14/2005 1:13PM After finding 3 problems with our B tables conversion we are rerunning 12-28-05. Fixes were in the stf903c macro module. ----*; libname stf904 '/pub/data/stf904'; filename varlabsa '/pub/data/stf904/Varlabs/atables.sas'; filename varlabsb '/pub/data/stf904/Varlabs/btables.sas'; *---load the conversion macro---; %include 'stf904c.sas'/NOsource2; *----define a "driver" macro that can be invoked once for each file to be converted. A slight shortcut.---; %macro docnvt(dsno,geopref=us,tabtype=b,chariter=000,maxobs=999999,geosonly=0) ; %if %length(&dsno)=1 %then %let dsno=000&dsno; %else %if %length(&dsno)=2 %then %let dsno=00&dsno; %else %if %length(&dsno)=3 %then %let dsno=0&dsno; filename in&tabtype pipe "unzip -p ../06308-&dsno.-Data[1].txt.zip" ; %local dsetname itername; %if &geosonly %then %let dsetname=&geopref.geos; %else %if &tabtype=a %then %let dsetname=&geopref.atbls; %else %do; %if &chariter=000 %then %let itername=tot; %else %if &chariter=001 %then %let itername=whi; %else %if &chariter=002 %then %let itername=bla; %else %if &chariter=003 %then %let itername=ami; %else %if &chariter=007 %then %let itername=api; %else %if &chariter=023 %then %let itername=oth; %else %if &chariter=100 %then %let itername=his; %else %if &chariter=120 %then %let itername=wnh; %else %if &chariter=121 %then %let itername=bnh; %else %if &chariter=122 %then %let itername=inh; %else %if &chariter=123 %then %let itername=anh; %else %if &chariter=124 %then %let itername=onh; %else %put ***Add code to assign name for chariter &chariter ***; %let dsetname=&geopref.btb&itername; %end; %*---ready to invoke the conversion macro. It reads the data from ascii file ina or inb and writes the results to either sasouta or sasoutb---; %put dsetname=&dsetname; %stf904c( %if &tabtype=a %then %do; fileina=ina,sasouta=stf904.&dsetname,varlabs=varlabsa, %end; %else %do; fileinb=inb,sasoutb=stf904.&dsetname,varlabs=varlabsb, %end; %if &geosonly %then %do; geosonly=1, %end; obs=&maxobs,formats=1); run; filename in&tabtype clear; *---and now create the subset with sumlevs 010 (Nation), 040(state) and county(050) only---; %let dsetname=stf904.&dsetname; proc print data=&dsetname(obs=100 keep=_char_ pop100); by Chariter SumLev notsorted ; id geocomp state county areaname; title2 "Partial Print of Ids for &dsetname"; run; proc freq data=&dsetname(keep=sumlev state geocomp chariter); run; %mend docnvt; options mprint; %*docnvt(1,tabtype=a,geosonly=1); %docnvt(1,tabtype=a,maxobs=999999); %docnvt(2,tabtype=b,chariter=000); %*docnvt(3,tabtype=b,chariter=001); %docnvt(4,tabtype=b,chariter=002); %docnvt(5,tabtype=b,chariter=003); %docnvt(9,tabtype=b,chariter=007); %docnvt(25,tabtype=b,chariter=023); %docnvt(26,tabtype=b,chariter=100); %docnvt(46,tabtype=b,chariter=120); %docnvt(47,tabtype=b,chariter=121); %docnvt(48,tabtype=b,chariter=122); %docnvt(49,tabtype=b,chariter=123); %docnvt(50,tabtype=b,chariter=124);