x cd /pub/data/stf903x2/Tools; %let pgm=uscnvts_stf903x2; filename pgm "&pgm..sas"; /*---Access 1990 stf3 datasets and create standard extract datasets for US coverages.--; Code has been customized to process the stf3C geographic levels. Creates datasets: stf903.usstcnty (data step view to concatenate state and county level summaries) stf903x2.usregiv .usstcnty .usplaces (only of size 10000+) .usmcds90 (only in selected states) .usmsas90 .uszips90 .uszipcos90 John Blodgett, Evelyn Cleveland, OSEDA, U. of Missouri Outreach & Extension. Nov. 2002 Rerun 11-21-02 after creating landsqmi and altering defn of poppersqm. Rerun 11-25-02 after change to avgageunit var. Creating stf903x2.usnewcos 1-6-02 to allow working with dp32kt. Adding uszipcos90 - the 820 summary level. Rerun 07-13-03 after fix to HHPop variable defn. Rerun 10-28-08 to include AvgHValue variable. John Blodgett, OSEDA, U of MO Outreach and Extension Under contract with the Missouri Census Data Center. ---*/ 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; %macro cnvtmeta(mode,moregeos=,setin=,setout=); %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; *---------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--; retain _val .; length geocode $16 slvl $3; if SumLev=' ' then SumLev=slvl; *---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('010') geocode=' '; when('020') geocode=reg; when('030') geocode=div; when('040') geocode=state; when('050') geocode=county; when('061','062') do; geocode=%concatd(county,cousubfp); SumLev='060'; end; when('160','161') do; geocode=%concatd(state,placefp); SumLev='160'; end; /*<=========================Comment out===================================== when('170') geocode=%concatd(state,concit); when('172') geocode=%concatd(state,concit,placefp); when('250') geocode=aianhh; when('260') geocode=%concatd(aianhhfp,state); when('270') geocode=%concatd(aianhhfp,cnty); when('271') geocode=%concatd(aianhhfp,cnty,cousubfp); when('273') geocode=%concatd(aianhhfp,cnty,cousubfp,placefp); when('252') geocode=aianhh; when('262') geocode=%concatd(aianhhfp,state); when('272') geocode=%concatd(aianhhfp,cnty); when('275') geocode=%concatd(aianhhfp,cnty,cousubfp); when('276') geocode=%concatd(aianhhfp,cnty,cousubfp,placefp); when('254') geocode=aianhh; when('264') geocode=%concatd(aianhhfp,state); when('274') geocode=%concatd(aianhhfp,cnty); when('277') geocode=%concatd(aianhhfp,cnty,cousubfp); when('278') geocode=%concatd(aianhhfp,cnty,cousubfp,placefp); when('256','291','292') geocode=%concatd(aianhhfp,tract); when('258','293','294') geocode=%concatd(aianhhfp,tract,bg); when('251','253','255') geocode=%concatd(aianhhfp,aits); when('257') geocode=%concatd(aianhhfp,aits,tract); when('259') geocode=%concatd(aianhhfp,aits,tract,bg); when('290') geocode=%concatd(aianhhfp,aits,state); when('280','283','286') geocode=%concatd(state,aianhhfp); when('282','285','288') geocode=%concatd(state,aianhhfp,cnty); when('261','265','267') geocode=%concatd(state,aianhhfp,cnty,cousubfp); when('263','266','268') geocode=%concatd(state,aianhhfp,cnty,cousubfp,placefp); when('281','284','287') geocode=%concatd(state,aianhhfp,aits); when('230') geocode=%concatd(state,anrc); ===========================End commented out================================ */ when('300') do; SumLev='380'; geocode=msacmsa; end; when('310') do; geocode=%concatd(msacmsa,state); SumLev='381'; end; /* ========================Comment Begin========= when('382') geocode=%concatd(msacmsa,state,placefp); when('383') geocode=%concatd(msacmsa,state,cnty); when('384') geocode=%concatd(msacmsa,state,cousubfp); ==========================End Comment============== */ when('301') do; geocode=pmsa; SumLev='385'; end; when('311') do; geocode=%concatd(pmsa,state); SumLev='386'; end; /* ========================Comment Begin========= when('387') geocode=%concatd(pmsa,state,cnty); when('388') geocode=%concatd(pmsa,state,cousubfp); when('370') geocode=necma; when('371') geocode=%concatd(necma,state); when('372') geocode=%concatd(necma,state,placefp); when('373') geocode=%concatd(necma,state,cnty); ==========================End Comment============== */ when('800') do; geocode=zip; SumLev='860'; end; when('820') do; if p1i1=0 then delete; *---get rid of these pesky empty parts---; sumlev='871'; geocode=%concatd(county,zip); if index(areaname,'(pt.)') then areaname=put(zip,$zipname.); format county $county.; end; otherwise delete; end; %include '/pub/data/stf903x2/Tools/invoke_dovars.sas' / NOsource2; Obs+1; keep geocode sumlev slvl state county areaname &moregeos; keep TotPop -- Obs; drop _val geocomp; run; %mend cnvtmeta; options mprint nosymbolgen; %cnvtmeta(data,setin=usregdiv,moregeos=reg div) ; data stf903.usstcnty/view=stf903.usstcnty; set stf903.usstates stf903.uscntys open=defer; run; options nomprint; /* =======================Begin comment================ %cnvtmeta(data,setin=usstcnty,moregeos=fipco); %cnvtmeta(data,setin=usplaces,moregeos=placefp place); %cnvtmeta(data,setin=usmcds,setout=usmcds90,moregeos=cousubfp cousubce msacmsa pmsa fipco); %cnvtmeta(data,setin=usmetros,setout=usmsas90,moregeos=msacmsa pmsa); %cnvtmeta(data,setin=uszipcos,setout=uszipcos90,moregeos=zip fipco msacmsa pmsa reg div) ======================End comment================== */ %cnvtmeta(data,setin=uszips,setout=uszips90,moregeos=zip); *---Create special set for counties that changed codes over the decade--; data stf903x2.usnewcos(label='Counties with new FIPS county codes for 2000'); set stf903x2.usstcnty; where county in ('12025' ) ; *--others??--; select (county); when ('12025') county='12086'; end; geocode=county; run ; proc datasets library=stf903x2 nolist ; modify usplaces; index delete geocode; index create geocode; modify uszipcos90; index create state; index create geocode; modify uszips90; index create geocode; index create state; quit;