*---------/mscdc/sas/formats/Tools/Sfnemcnm.sas----------*; x cd /mscdc/sas/formats/Tools; options mprint; %pgm(Sfnemcnm) options nomprint; /* This creates the fnemcnm format which relates fips state and county subdiv. code to their names for New England states: ct, me, ma, nh, ri, vt. This format was developed as a result of work on crahmda products for New England. Input is the New England index file relating Metro Area or non-metro remainder of state data to New England county subdivisions. The argument is the 2-digit fips state code concatenated with the 5-digit fips MCD/CCD code. The result field is the areaname from stf903 subsets with data pertinent to cra/hmda and banking. Format will be used in the creation of tract level cra/hmda income category reports indexed to metro (determined by mcd in New England) JWS 11/97 */ %let yr=96; *******Year for the codes (updated as of July); libname library clear; libname library '/mscdc/sasctlgs'; libname crahmda '/uic/products/crahmda'; filename text '/mscdc/sas/formats/Sfnemcnm.sas'; title 'Creation of July 1996 New England Census County Subdivision ' 'to Name Format'; data genfmtin;*---create correspondence of 2 to 4 digit cmsas---*; length arg $7 label $30 dir $9; set crahmda.idxne96(keep=state cousubfp areaname); arg=state || cousubfp; l=index(areaname,' '); dir=scan(areaname,1); if dir='North' then areaname='N' || substr(areaname,l); else if dir='South' then areaname='S' || substr(areaname,l); else if dir='East' then areaname='E' || substr(areaname,l); else if dir='West' then areaname='W' || substr(areaname,l); else if dir='Northwest' then areaname='NW' || substr(areaname,l); else if dir='Southwest' then areaname='SW' || substr(areaname,l); else if dir='Southeast' then areaname='SE' || substr(areaname,l); else if dir='Northeast' then areaname='NE' || substr(areaname,l); l=length(areaname); if index(areaname,' town') gt 0 then l=index(areaname,' town')-1; label=substr(areaname,1,l); keep arg label; run; proc sort data=genfmtin; by arg label; run; data dups;set genfmtin;by arg;if not first.arg or not last.arg;run; proc print;title2 'dups in genfmtin';run; %genfmat(setin=genfmtin,fmatname=fnemcnm,arglen=7, argvars=arg,labelvar=label,labellen=30,other=' ',savedoc=0); title2 'Partial Print of Format Source'; data _null_; infile text obs=50; input; file print; put _infile_; run; *---test the format---*; data _null_;length result $30; set genfmtin (keep=arg label); if mod(_n_,100)=0; result=put(arg,$fnemcnm.); run; proc print;title2 'Test of New England MCD to Name Format'; run; run;