x cd /pub/sas/formats/Tools; %let pgm=genuspow; filename pgm "&pgm..sas"; *--generate the $uspow format code that provides names of the custom pows used on the 1990 stf420 files. We use an ascii file provided with the stf420 data as the source. Based on old setup run on oseda many years earlier where we did one such format per state. jgb, OSEDA, May, 2008. --*; filename in '/pub/data/census_1990/stf420/uspow.txt'; filename netowns '/pub/data/census_1990/stf420/newenglandtowns.csv'; filename text '/pub/sas/formats/Suspow.sas'; filename text2 '/pub/sas/formats/Smopow.sas'; options NOmprint; *--read New England towns file (generated using geocorr90 web app) and save as tool to get cousubfp codes for building args in NE--; data netowns; infile netowns dsd firstobs=2; length CountyCK CouSubFP $5 _cntyname $40 TownName $40; input countyCK -- TownName; drop _: ; run; proc print data=netowns; by countyCK; id countyCK; run; data us mo; length state $2 cnty $3 pow 4; retain state cnty county; infile in missover; input co $char5. @; if co ne ' ' then do; county=co; state=substr(county,1,2); cnty =substr(county,3,3); if state in ('09','23','25','33','44','50') then do; _neweng=1; retain _neweng; input _name $6-40 ; _name=scan(compress(_name,"'"),1); set netowns; retain cousubfp; if scan(Townname,1) ne _name or (county ne countyCK) then do; put '***Logic Problem using netowns ' / _all_; abort abend; end; end; else _neweng=0; end; *--county/town header record processing--; else do; input areaname $ 6-71 _pow $72-73; if notdigit(compress(_pow)) then do until (notdigit(compress(_pow))=0); input _pow $72-73; end; pow=_pow; length arg $12; if _neweng then arg=county||cousubfp||put(pow,z2.); else arg=county||put(pow,z2.); output us; if state='29' then output mo; *--gets written to both--; end; drop _: ; run; proc sort data=us nodupkeys; by arg; run; %genfmat(fmatname=uspow, sasin=us, argvars=arg, arglen=12, textfile=text, savedoc=1, other=%str( ), library=library, labelvar=areaname, labellen=66) run; %genfmat(fmatname=mopow, sasin=mo, argvars=arg, arglen=7, textfile=text2, savedoc=1, other=%str( ), library=library, labelvar=areaname, labellen=66) run; *--test it--; data _null_; pow='2900101'; put pow $mopow.; pow='0600919'; put pow $uspow.; pow12='090030206001'; put pow12 $uspow.; run;