x cd /pub/data/stf903x2/Tools; %let pgm=moilkscnvts_stf903x2; filename pgm "&pgm..sas"; /*---Access 1990 stf3 datasets and create standard extract datasets for the tri-state coverages.--; Code has been customized to process the stf3C geographic levels. Creates datasets: stf903x2.mostcnty moplaces momcds90 momsas90 mozips90 stf903x2.ksstcnty ksplaces ksmcds90 ksmsas90 kszips90 stf903x2.ilstcnty ilplaces ilmcds90 ilmsas90 ilzips90 stf903x2.mobgs00 motrs00 (added by jgb 12-5-02) stf903x2.mozipcos, ilzipcos and kszipcos added as SQL views 7-2-03) John Blodgett, Evelyn Cleveland, OSEDA, U. of Missouri Outreach & Extension. (Nov. 2002) Rerun 11-11-02 to make necessary corrections in the following tables: avg. hh income, workers living in a place, disability by age current arm forces and sales-office occupations. ejc Rerun 11-12-02 to make correction on disability univers (pers 65+) by ejc Correction on Mean Travel to Work Time on 11-13-02 by ejc Added RefTabs to each table...corresponding/reference tables from stf903. ejc 11-14-02 Rerun 11-21-02 after changing defn of PopPerSQM and adding LandSQMI variable. Rerun 11-25-02 after correcting calculation of AvgAgeUnit. ejc Rerun 07-13-03 after correcting calculation of HHPop. jgb Rerun 10-28-08 after adding AvgHVal variable . jgb Under contract with the Missouri Census Data Center. Rerun 10-29-15 to create mobgs90 and motrs90. ---*/ libname stf903 "/pub/data/stf903"; libname stf903x2 "/pub/data/stf903x2"; %let filetype=stf903x2; title "&pgm: Create stf903x2 Extract Datasets from stf903 Complete Table Datasets"; %global Pctof table curtable curtabno dvmode; %let curtabno=0; %let reftables=; %let dvmode=data; *--this include statement is now obsolete since we use the dovars macro out of the autocall library--; %***include '/pub/sas/macros/dovarsf3.sas'/source2; *<----dovars macro defined here-------------------; *----Doing rerun 10/08 we find that the stf903.momcds data set is gone. So we recreate it here as a subset view of moi--; proc sql; create view stf903.momcds as select * from moi where slvl='060'; quit; %macro cnvtmeta(mode,moregeos=,setin=,setout=,sumlev=); %*--adding sumlev parm 10-29-15---; %global dvmode; %let dvmode=&mode; %*----------macro has been edited for this app so that meta mode not applicable! ---; %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 &sumlev ne %str() %then %do; where slvl="&sumlev"; %end; if geocomp in(' ','00'); *--so even if not on the input set this works--; 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('040') geocode=state; when('050') geocode=county; when('060') do; geocode=%concatd(county,cousubfp); end; when('140') do; geocode=%concatd(county,tract); end; when('150') do; geocode=%concatd(county,tract,bg); end; when('155') do; geocode=%concatd(county,placefp); length _temparg $7; _temparg=state||placefp; areaname=put(_temparg,$fplace.); drop _temparg; end; when('160') do; geocode=%concatd(state,placefp); end; when('300') do; SumLev='380'; geocode=msacmsa; end; when('310') do; geocode=%concatd(msacmsa,state); SumLev='381'; end; when('301') do; geocode=pmsa; SumLev='385'; end; when('311') do; geocode=%concatd(pmsa,state); SumLev='386'; end; when('800') do; geocode=%concatd(state,zip); SumLev='871'; end; when('820') do; geocode=%concatd(county,zip); if p1i1=0 then delete; SumLev='881'; end; 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"); %attrmeta ; 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; %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(meta,setin=mostcnty,moregeos=fipco) ; /*<=========================Comment out===================================== %cnvtmeta(data,setin=mostcnty,moregeos=fipco); %cnvtmeta(data,setin=moplaces,moregeos=placefp place); %cnvtmeta(data,setin=momcds,setout=momcds90,moregeos=cousubfp cousubce msacmsa pmsa fipco); %cnvtmeta(data,setin=mozips,setout=mozips90,moregeos=zip); %cnvtmeta(data,setin=mobgs00,setout=mobgs00,moregeos=tract bg) %cnvtmeta(data,setin=motrs00,setout=motrs00,moregeos=tract) %cnvtmeta(data,setin=ilstcnty,moregeos=fipco); %cnvtmeta(data,setin=ilplaces,moregeos=placefp place); %cnvtmeta(data,setin=ilmcds,setout=ilmcds90,moregeos=cousubfp cousubce msacmsa pmsa fipco); %cnvtmeta(data,setin=ilzips,setout=ilzips90,moregeos=zip); %cnvtmeta(data,setin=ksstcnty,moregeos=fipco); %cnvtmeta(data,setin=ksplaces,moregeos=placefp place); %cnvtmeta(data,setin=ksmcds,setout=ksmcds90,moregeos=cousubfp cousubce msacmsa pmsa fipco); %cnvtmeta(data,setin=kszips,setout=kszips90,moregeos=zip); ===========================End commented out================================ */ %cnvtmeta(data,setin=moi,setout=motracts90,moregeos=tract,sumlev=140) %cnvtmeta(data,setin=ksi,setout=kstracts90,moregeos=tract,sumlev=140) %cnvtmeta(data,setin=moi,setout=mobgs90,moregeos=tract bg,sumlev=150) %cnvtmeta(data,setin=ksi,setout=ksbgs90,moregeos=tract bg,sumlev=150) %contdir(stf903x2) /* =======================Begin comment================ proc sql; create view stf903x2.mozipcos90 as select * from uszipcos90 where state='29'; create view stf903x2.ilzipcos90 as select * from uszipcos90 where state='17'; create view stf903x2.kszipcos90 as select * from uszipcos90 where state='20'; quit; ======================End comment================== */