x cd /pub/sas/formats/Tools; %let pgm=gen_tr2puma; filename pgm "&pgm..sas"; *--generate the $trpuma format code to look up 2012 PUMA codes (within state) for census tracts. Uses georef.tract_master as source. jgb, 6-17. --; libname georef '/pub/data/georef' access=readonly; title 'Generate $tr2puma SAS format codes'; libname sasfmt "/pub/sas/catalogs"; libname user '/SAS_temp/user'; filename text "/pub/sas/formats/Str2puma.sas"; data values; set georef.tract_master16(keep=state esriid county puma county county10c tract tract10c);*<--as created in georef/Tools/tract_master16_temp--; output; *--the format will work with the new tract ids or the old. Here we output cases where the tract (or county code) changed--; if (tract10c ne tract) or (county10c ne county) then do; esriid=county10c||compress(tract10c,'.'); output; ** keep esriid puma; end; run; proc sort data=values nodupkeys; by esriid; run; %genfmat(sasin=values, fmatname=tr2puma, fmatlib=sasfmt, argvars=esriid, arglen=11, labelvar=puma, labellen=5,other=' ',savedoc=1, runproc=1) run; proc format library=sasfmt; %include text; run; data _null_; infile text obs=50; input; file print; put _infile_; title2 "First 50 Lines of Str2puma.sas file"; run; *--test use--*; options fmtsearch=(sasfmt work); data _null_; length puma $5 tractid $11; **put fipco= fipco $cocbsa&yr._.; retain codes '06037800204 04019470500 04019005300 36085008900 36085009700'; do i=1 to 5 ; tractid=scan(codes,i); put tractid= tractid $tr2puma.; end; stop; run;