x cd /pub/data/stf903x2/Tools; %let pgm=mocustomgeos; filename pgm "&pgm..sas"; /*---Access 1990 stf3 datasets and create standard extract datasets for various Missouri custom geographies.--; Creates stf903x2 datasets: mocd108 mohouse mosenate John Blodgett, OSEDA Under contract with the Missouri Census Data Center. 11-14-02: Running for state legislative districts. 11-20-02: Running for Mo school districts (complete and within-county). 11-21-02: Rerunning after fix to pop density variable. 11-25-02: Rerunning after correction of avg. age. of housing unit calculations. ejc 12-14-02: Running for moregns data (dot, ded, rpc and umx) in morgns00. ---*/ libname stf903 "/pub/data/stf903"; libname stf903x2 "/pub/data/stf903x2"; %let filetype=stf903x2; title "&pgm: Create stf903x2 Extract Datasets for MO Legislative Districts"; %global Pctof table curtable curtabno dvmode; %let curtabno=0; %let reftables=; %let dvmode=data; %macro cnvtmeta(mode,moregeos=,setin=,setout=,sumlev=); %global dvmode; %let dvmode=&mode; %if &setout=%str() %then %let setout=&setin; %if &dvmode = %str(data) %then %do; *---------Here is the conversion data step-------------*; data stf903x2.&setout ; length default=5; set stf903.&setin; ***(rename=(slvl=SumLev)); if geocomp in(' ','00'); *--so even if not on the input set this works--; %if &sumlev ne %str() %then %do; where SumLev in (%qlist(&sumlev)); %end; retain _val .; length geocode $16 slvl $3; if SumLev=' ' then SumLev=slvl; fipco=county; *---Note we reference geovars reg and div in 1990 which are called region and division for 2000--; select(SumLev); *---Assign the standardized Geographic Code to uniquely ID the geographic area--; when('500') geocode='29-'||cd108; when('610','620') geocode=geocode; when('sdu','sde','su2','se2') geocode=geocode; when('rpc','ded','dot','umx') geocode=geocode; otherwise delete; end; %end; %else %if &dvmode=%str(meta) %then %do; *------Here is the data step that generate sf3x.Variables when dvmode=meta-----------; data stf903x2.Variables(label="Meta data describing the variables on these datasets"); attrib Name label='Variable Name' length=$32 Label length=$80 Definition length=$200 label='Definition - Code used to derive' Comment length=$400 Format length=$16 TypeLen length=$8 label='Variable type and length' Universe length=$64 UnivVar length=$32 label='Universe Variable' WtVar length=$32 label='Weight Variable' PctFlag length=3 label='Pct Variable Flag' Table length=$64 TableNo length=3 label='Table #' Keywords length=$80 Year length=$4 Source length=$40 ; *** OtherYears label='Other Years Available' length=$32; retain Year '1990'; *<===================; retain Source 'Summary File 3, 1990 Census'; *<===============; %end; %else %put ***** dvmode parm value not recognized: value= &dvmode ; %include '/pub/data/stf903x2/Tools/invoke_dovars.sas' / NOsource2; %if &dvmode=%str(data) %then %do; Obs+1; keep geocode sumlev slvl state county areaname &moregeos; keep TotPop -- Obs; drop _val geocomp; run; proc print data=stf903x2.&setout(obs=25 keep=_char_ TotPop Obs); title "First 25 Observations (Selected ID Variables) on stf903x2.&setout"; run; %end; %else %if &dvmode=%str(meta) %then %do; *-----meta processing-----------------------------; run; options nonumber nodate orientation=landscape nocenter; ods printer pdf file="../Variables.pdf" ; ods path work.templat(update) sashelp.tmplmst(read); proc template; %include '/pub/sascode/osedablue.sas'; *<====Optional style thing===; run; ods html file='../Variables.html' style=osedablue; ods listing close; proc print data=stf903x2.Variables label; where pctflag=0 or UnivVar=' '; *<--do not show the Pct variables unless they are stand-alone--; by table notsorted universe notsorted; id name; var label--comment UnivVar WtVar; title 'Metadata for the stf903x2 Filetype (Partial listing of Variables dataset)'; footnote 'Note: If Universe Variable has a value then there is a corresponding Pct Variable'; footnote2 'Example: PctWhite is defined and is 100*White/TotPop'; run; ods printer close; ods html close; %end; %mend cnvtmeta; options NOmprint nosymbolgen; title2 "Revised as of &sysdate &systime"; %cnvtmeta(data,setin=molegdists02,setout=mocd108,moregeos=cd108,SumLev=500); options nomprint; %cnvtmeta(data,setin=molegdists02,setout=mohouse,moregeos=House,SumLev=620); %cnvtmeta(data,setin=molegdists02,setout=mosenate,moregeos=Senate,SumLev=610); %cnvtmeta(data,setin=moschls00,setout=moschls00,moregeos=desedist ncescode,SumLev=sde sdu); *<======Custom step to fix the partflag variable on BOTH stf903.moschlcos00 and stf903x2.moschlcos00===; data stf903.moschlcos00; set stf903.moschlcos00; by ncescode notsorted; if not (first.ncescode and last.ncescode) then partflag='y'; run; %cnvtmeta(data,setin=moschlcos00,setout=moschlcos00,moregeos=desedist ncescode county cnty partflag,SumLev=se2 su2); %cnvtmeta(data,setin=moregns,setout=moregns00,moregeos=region dot ded_region umx2 rpc); /*<=========================Comment out===================================== ===========================End commented out================================ */ %contdir(stf903x2)