x cd /pub/sas/formats/Tools; %let pgm=genusplco; filename pgm "&pgm..sas"; *--regenerate the $usplco and $moplco lookup-table using corrlst.usplco2k data and genfmat macro--; *--Updating using 2010 data from pl94, replacing the old 2000 vintage values--; filename text '/pub/sas/formats/Susplco.sas'; filename text2 '/pub/sas/formats/Smoplco.sas'; %*ibname(corrlst); %libname (pl942010); proc sort data= pl942010.usplaces(where=(sumlev='155') keep=sumlev state placefp county totpop) out=placecos; by state placefp descending totpop; run; data us mo; *et corrlst.usplco2k; set placecos; if _N_ le 5 then put / _all_; by state placefp; if first.placefp; *<-----select the "primary" county for the place, i.e. the one with the largest portion of the place pop per 2k census---; length label $80; label=county ||' '||put(county,$county.); if not last.placefp then substr(label,6,1)='+'; *--the 6th character is blank or + to indicate whether or not the place is entirely within the primary county---; keep state placefp label; output us; if state='29' then output mo; run; options nomprint; libname sasctlgs clear; libname sasctlgs '/pub/sas/catalogs'; *<----to get write access---; %genfmat(fmatname=usplco, arg=state placefp, arglen=7, labelvar=label, runproc=1, setin=us) %genfmat(fmatname=moplco, textfile=text2, arg=state placefp, arglen=7, labelvar=label, runproc=1, setin=mo) *--test it--; data _null_; placefp='2900244'; put placefp $fplace. +1 placefp= $usplco.; placefp='2900712'; put placefp $fplace. +1 placefp= $moplco.; run;