x cd /pub/data/mable09/Tools; %let pgm=genmable2k_02; filename pgm "&pgm..sas"; *--Generate the revised edition of mable2k data base. Here we add new items from: 1. the tiger108 datasets -and- 2. cbsa 2004 related data in newly created &stab.cocds2 datasets. (see tiger_codes108 setup). We combine everything in a new view, such as mable2k.mov2 . John Blodgett, Aug, 2003. Rev. 2005, 2006 --*; /* Update History Aug. 27, 2003: Start. Sep. 13, 2003: Add county02 and fix logic to read cocds02 using county02 as key. For CO and VA, at least. Sep. 29, 2003: Add **temp** code to avoid aborting when data for Bennett co, SD comes up missing. June 18, 2005: After migrating to v9, 64-bit format we have to recreate these views. We now point to the more recent georef datasets for cbsa codes, vintage November, 2004. Sep. 9, 2006: Change the defn of the XXv2 view by keeping 3 more vars - ua, ur and puma5 - from the blks2a dataset. But reran the view defn only for South Dakota where this makes a difference (Bennett county was missing in mable2k.sdblks dataset). */ %include '/pub/sas/autoexec.sas'; options msglevel=i; ** fullstimer; %let mablepath=%str(/pub/data/mable09); libname mable2k "&mablepath"; libname georef '/pub/data/georef' access=readonly; options mprint; %macro doit(state,stab); %*---Create the cocds2 dataset with the 03 cbsa related codes--; data mable2k.&stab.cocds2(label="More county based codes including 2003 cbsas" index=(county)); *---the georef.cbsacos dataset was regenerated June 05 to update to Nov 04 cbsa defns---; set georef.cbsacos (keep=state county cbsa metrodiv cbsatype year where=(state="&state")); if cbsa ne ' ' and cbsa ne lag(cbsa) then set georef.cbsas(keep=cbsa csa) key=cbsa; if cbsa=' ' then csa=' '; rename year=cbsayear; run; *---And the view that combines the two...--; data mable2k.&stab.v2/view=mable2k.&stab.v2; merge mable2k.&stab.blks(in=inblks1) mable2k.&stab.blks2(in=inblks2 keep=county tract block ua ur ur90 puma5) mable2k.&stab.blks2a(in=inblks2a keep=county tract block ua ur puma5 ur00cor ua00cor ua90 ua90red ur90 ur90red cd108); by county tract block; if not (inblks1 and inblks2 and inblks2a) then do; put "*************Error: Missing a block obs on one of the 3 blks datasets****"; if county ne '46007' then abort 500; *<=================TEMPORARY!!!!!!!==============; end; county02=county; if county='51560' then county02='51005'; else if state='08' and placefp='09280' then county02='08014'; if first.county then do; set mable2k.&stab.cocds1(rename=(county=countyck)); %if &state ne 08 and &state ne 51 %then %do; set mable2k.&stab.cocds2(rename=(county=countyck2)); %end; end; %if &state=08 or &state=51 %then %do; _save=county; drop _save; county=county02; %*--do keyed read on the cocds2 set using county02 as key--; if county ne lag(county) then set mable2k.&stab.cocds2 key=county; if _iorc_ then do; put "*****ERROR doing keyed read of &stab.cocds2 dataset for county " county $5. +1 county $county. ; _error_=1; end; county=_save; countyck2=county; %end; %*---code to customize defn of cbsa-related codes for Sullivan city portion of Crawford co, MO.--; %if &state=29 %then %do; if county='29055' then if placefp='71440' then do; cbsa='41180'; cbsatype='Metro'; cbsayear='2004'; end; else do; cbsa=' '; cbsatype=' '; cbsayear=' '; end; %end; if county ne countyck then do; put "*************Error: county code on &stab.cocds1 dataset does not match that on the blks datasets****"; abort 600; end; if county ne countyck2 then do; put "*************Error: county code on &stab.cocds2 dataset does not match that on the blks datasets****"; abort 601; end; drop countyck countyck2; format county $5.; run; %mend doit; options NOmprint; /* =======================Begin comment================ %dostates(29); %dostates(01 02 04 05 06 08 09 10 11 12 13 15 16 17,msgs=1); %dostates(18 19 20 21 22 24 25 26 27 28 30 31 32 33 34 35 36,msgs=1); %dostates(23 37 38 39 40 41 42); %dostates(44 45 46 47 48 49 50 51 53 54 55 56); *--9-9-06--; %dostates(46); *<---we changed the keep list for the blks2a dataset so we pick up ua, ur and puma5 form it. Needed this to fix problem with mable2k.sdblks dataset which had no data for Bennett county--; ======================End comment================== */ %dostates(02 08 51);