%let path=%str(p:\mcdc\acs2008_3yr); %let pgm=upload_edit_usmcdcprofiles3yr; filename pgm "&path\&pgm..sas"; x cd &path; *---Being coded and run 11-3-09. Creates datasets acs2008.usmcdcprofiles3yr and acs2008.allgeos3yr ----*; *---Submitted from Windows but most of the work is done on Unix via a rsubmit block. This pgm file is saved in Tools; libname acs2008 "&path"; filename rlink clear; filename rlink 'c:\tcpunix2.scr'; signon mcdc; options ls=132; rsubmit; options ls=132; libname temp '/pub/data/temp'; libname aix2008 '/pub/data/acs2008'; libname acs2007 '/pub/data/acs2007'; *<---previous years data---; filename pgmaix '/pub/data/acs2008/Tools/upload_edit_usmcdcprofiles3yr.sas'; proc upload infile=pgm outfile=pgmaix status=no; run; *<---upload this program file---; /* =======================Comment out. Already ran========================================== proc upload data=acs2008.usmcdcprofiles out=temp.usmcdcprofiles3yr status=no; run; proc upload data=acs2008.allgeos out=temp.allgeos3yr status=no; run; ======================End comment======================================================= */ data aix2008.usmcdcprofiles3yr(label='MCDC profile extract for all US areas with 205,000+ population based on 2006-2008 surveys' compress=Yes); if 0 then set aix2008.usmcdcprofiles(drop=datecreated); *--this sets up the program data vector, establishing the variable order with lengths, labels and formats----; set temp.usmcdcprofiles3yr; *---this puts the data into the pdv slots.----; *** DateCreated=today(); Years='2006-2008'; period='3yr'; Geocomp_name=put(geocomp,$geocomp.); if sumlev='795' then do; length PUMA $5; puma=substr(geoid,10,5); if state='29' then Areaname=put(puma,$mopuma.); end; if sumlev='160' then placefp=substr(geoid,10,5); run; %let period=3yr; %let year=2008; libname georef '/pub/data/georef' access=readonly; *-----This step adapted from the cnvt_geo_files.sas setup used to read the geogrpahic header txt files directly with 2007 data. But now we are using a set stmt to access the dataset created by bce on windows as the data source. We have to do some renaming, reformatting and re-ordering of variables to remain consistent.-----; data aix2008.allgeos3yr(label='Geographic ID data for the 3-year period estimates' compress=Yes); length SumLev $3 geoid $20 geocode $12 Name $120 AreaName $100 Geocomp_Name $64 State Stab $2 Geocomp $2 LogRecno 8 County $5 CBSA $5 cbsaType $5 UA $5 PlaceFP $5 PUMA5 $5 sdelm sdsec sduni $5 Region Division $1 CongDist $2 MetroDiv $5 CSA $3 NECTA $5 ; label sumlev=' ' geoid=' ' areaname=' ' state=' ' geocomp=' ' logrecno=' ' county=' ' cbsa=' ' ua=' ' placefp=' ' puma5=' ' name=' '; cbsaType=' '; CBSAYr=' '; *<--being retained because we did a keyed read below--; ****The old input statement is being commented out here, but left in just to see what we used to do.... input @7 Stab $2. SumLev $3. Geocomp $2. LogRecNo 7. +1 Region $1. Division $1. @26 state $2. _cnty $3. cousubfp $31-35 placefp $36-40 cbsa $76-80 metrodiv $84-88 csa $81-83 necta $91-95 ua $104-108 CongDist $114-115 puma5 $166-170 @138 (sdelm sdsec sduni)($5.) @176 geoid $20. @216 Name $120.; set temp.allgeos3yr(rename=(sumlevel=sumlev component=geocomp stusab=stab place=placefp county=_cnty cdcurr=CongDist areaname=name) drop=fileid US tract blkgrp vtd zcta: submcd taz statece sldl sldu uga puma1); if state='00' then state=' '; if stab=' ' and state=' ' then delete; geocode=substr(geoid,8); *---the codes identifying the area without SumLev and Geocomp and "US" from geoid-; if _cnty ne ' ' then County=State||_cnty; else County=' '; if geocomp ne '00' then do; Areaname=scan(name,1,';'); Geocomp_Name=scan(Name,2,';'); end; else Areaname=name; if state='29' and sumlev='795' then Areaname=puma5||' '||put(puma5,$mopuma.); *<---substitute names for the MO pumas---; if sumlev='050' then do; set georef.cbsacos(keep=county cbsa cbsatype MetroDiv Year rename=(year=CBSAyr)) key=county; if _iorc_ then _error_=0; else _cbsayr=CBSAyr; retain _cbsayr; end; else if cbsa ne ' ' then do; if index(areaname,'Micropolitan') then cbsatype='micro'; else cbsatype='metro'; cbsayr=_cbsayr; end; if stab='PR' and state=' ' then state='72'; *<---this little glitch caused grief so we fix it here---; label CongDist='110th (2008) Congressional District'; drop _: ; run; proc sort out=aix2008.allgeos3yr(index=(state) label="Geograpgy for ACS &period Data &year"); by State Logrecno; run; proc freq data=aix2008.allgeos3yr; table state sumlev; format state $state. sumlev $sumlev.; table state*stab/list missing; run; options ls=160; proc print data=aix2008.allgeos3yr(where= (state in('10','29')) drop=name geocomp_name); by state; id logrecno geoid; run; options ls=170 ps=120; proc print data=aix2008.usmcdcprofiles3yr(keep=_character_ totpop obs=100); title2 "First 100 Obs on acs2008.usmcdcprofile3yr"; format areaname $24. geocomp_name $12.; run cancel; *---Not worth it----; proc print data=aix2008.allgeos3yr(where=(state='29')); title2 "Subset of aix2008.allgeos3yr"; run; endrsubmit; %put ****all done*****;