x cd /pub/data/sf12010x/Tools; %let pgm=usblocksua; filename pgm "&pgm..sas"; *--This way-too-late setup will recreate all the state level blocks datasets to 1. add ua, uasc, uatype, urbanrur variables. 2. fix problem with all the comma10 formats that were assigned. 3. Re-sort the sets by state, county, tract and block. (They were by county, cousubfp, placefp, tract, block before, although we then created an index to get the new order. We make use of that index in this setup. 4. Will create new datasets with "ua" appended to name. But once all is verified we should rename them to replace input. ********************See blocksua_rename.sas for module that deletes the orginal xxblocks sets and renames the xxbloackua to xxblocks.***** jgb, 2-4-17. --*; libname sf12010x '/pub/data/sf12010x'; %libname (sf12010); *--complete table data sets stored here. They contain the geocodes being added here. The acutal data items do not change. (We do not have an urban or rual variable as part of our std extract.) --; options compress=binary; *--Get a list of all the variables with comma10. formats and override them.--; proc contents noprint data=sf12010x.moblocks(drop=_character_ pct:) out = contents(keep=name format formatl formatd); run; proc sql ; select trim(name) into :countsf10 separated by ' ' from contents where (format='COMMA' and formatl=10 and formatd=0); %put counts=&countsf10; %let state=29; %let stab=mo; %let state=10; %let stab=de; %macro doit(state,stab); data sf12010x.&stab.blocksua(label='Revised with UA ids added and sorted by tract and block within cnty' ); merge sf12010x.&stab.blocks (in=inx) sf12010.&stab.blocks(in=in1 keep=state county tract ua uasc uatype urbanrur esriid rename=(esriid=esriidck)); *---by stmt skipped. But we check to make sure esriid codes match.--; if esriid ne esriidck then do; put 'esriid check fails: ' esriid= esriidck= _n_= ; _nbad+1; if _nbad gt 5 then abort abend; end; format &countsf10 ; *--specify not to have a format associated with these--; format LandSQMI AreaSQMI 8.3; label UA="Urbanized area (rev. 2012)" uasc='UA size cd' uatype='UA type: C for cluster'; drop esriidck _: ; run; proc sort data=sf12010x.&stab.blocksua; by state county tract block; run; proc datasets nolist library=sf12010x; modify &stab.blocksua; index create county; quit; %mend doit; *--note that we do PR here---; %*dostates(01 02) ; %dostates(04 05 06 08 09 10 11 12 13 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 45 46 47 48 49 50 51 53 54 55 56 72, names=1,msgs=1);