x cd /pub/data/georef/Tools; %let pgm=regions_ded; filename pgm "&pgm..sas"; *---Read the CSV file from DED (Dave Peters) with their Mo region codes and counties. Use it to create georef.dedregions -- a new MCDC standard for breaking down the state into regions, and corrlst.mocodedrgns - a correlation list relating counties to these regions. Finally, creates $mocorgn format code (table) linking MO fips county codes to DED region codes and names, and $dedrgn that displays the region names with the 3-digit DED region code as arg. John Blodgett, OSEDA, U. of Missouri Outreach & Extension *** Rerun 7-27-01 after finding a bug in the input DED regions corr file re Texas County . *** Edited and rerun 9-8-01 to rename variables, datasets and formats to include "ded" . *** Outstanding minor problem: Why does the footnote "wrap" between words "georef" and "Tools" in footnote3? ---*; %libname(georef,opts=); libname corrlst '/pub/data/corrlst'; filename csvin '../regions.csv'; *--we exported this CSV file from excel spdsheet they sent--; /*<=========================Comment out===================================== ===========================End commented out================================ */ *-----------Part 1: Generate the data sets georef.dedregions and corrlst.mocodedrgns----------------------*; data georef.dedregions(label='Missouri Dept of Econ. Dev economic regions by county' drop=county fipco) corrlst.mocodedrgns(label='Missouri county to DED regions' drop=areaname); attrib DED_Region length=$3 label='DED Economic Region'; attrib county length=$5 label='County' format=$mocnty.; attrib cname length=$15; attrib AreaName length=$24; attrib Fipco length=$5 label='FIPS County Code'; infile csvin dsd missover firstobs=2 end=last; input county cname areaname id; if id=9 then id=10; *--merge St. Louis city with saint louis metro region--; if id=13 then AreaName='Springfield - Branson'; else if id=10 then AreaName='St. Louis MSA'; else if id=3 then AreaName='Kansas City MSA'; select (id); when(10) id=110; when(3) id=203; when(13) id=213; when(2) id=302; otherwise id=400+id; end; fipco=county; DED_Region=put(id,z3.); if DED_Region ne lag(DED_Region) then output georef.dedregions; output corrlst.mocodedrgns; drop cname id; run; proc sort data=georef.dedregions; by DED_Region; run; proc sort data=corrlst.mocodedrgns; by county; run; *-----------------Part 2: Generate the permanent format codes $dedrgn and $codedrgn---------------------*; filename text '/pub/sas/formats/Sdedrgn.sas'; %genfmat(fmatname=dedrgn,setin=georef.dedregions,argvars=DED_region,labelvar=areaname,arglen=3,labellen=24); run; data mocodedrgns; set corrlst.mocodedrgns; length labelvar $28; labelvar=DED_Region||' '||put(DED_region,$dedrgn.); run; filename text '/pub/sas/formats/Smocorgn.sas'; %genfmat(fmatname=mocorgn,setin=mocodedrgns,argvars=county,labelvar=labelvar,arglen=5,labellen=28); *--------------------Part 3: Generate some reports in the webrepts/geography directory----------------------*; options nodate nonumber ; %let htmldir=%str(/pub/reports/geography); ods html file="&htmldir/MO_DED_Region_Codes.html" ( title='Missouri Census Data Center Geography Report: Missouri DED Regions') contents="&htmldir/contents.html" (title='Contents') metatext=' name="author" content="John Blodgett, Missouri Census Data Center"> georef Tools Library'; title2 'Missouri Counties and DED Regions - as Stored in corrlst.mocodedrgns'; *---Create a dataset with the names of all the counties for 1 DED_Region stored in a character string--; proc sort data=corrlst.mocodedrgns out=Sorted_by_Region; by DED_Region county; run; data part1; set Sorted_by_Region; by DED_Region; length Counties $1000; retain counties; code=DED_Region; if first.DED_Region then Counties=put(county,$mocnty.); else Counties=trim(Counties)||", "||put(county,$mocnty.); if last.DED_Region then output; run; title3 'Part 1: Sorted by Region Showing Region Codes and Counties'; proc print data=part1 d label; format DED_Region $dedrgn.; label code='Region Code' DED_Region='Region Name'; id code; var DED_Region counties; run; proc print data=corrlst.mocodedrgns; title3 'Part 2: Sorted by County'; id fipco; var county DED_Region; format DED_Region $dedrgn.; run; ods html close;