x cd /pub/data/workflow/Tools; %let pgm=usflows2; filename pgm "&pgm..sas"; *---Combine data from the usbyres and usbywrk sets to create a single sas dataset with 2-way work count flows. Also create work sums on both ends by county (total residents and total workers in county) and then calculate the counts as a percent of the totals. Generate a series of pdf format reports showing work flows (2 sort orders, 2 separate reports) for all states. John Blodgett, OSEDA under a contract with the Missouri Census Data Center. March, 2003. ----*; title "workflow: &pgm : Create workflow.usflows2"; libname workflow '/pub/data/workflow'; libname user '/SAS_temp/user'; /*<=========================Comment out===================================== proc summary data=workflow.usbyres nway; class StateR CountyR; var count; output out=rsums sum=CRTotals ; run; proc summary data=workflow.usbywrk nway; class StateW CountyW; var count; output out=wsums sum=CWTotals ; run; proc datasets library=user nolist; modify wsums; index create countyw; quit; *----Use the county totals datasets to add the pct of all trips originating in the county and pct of work trips in the work county.--; data workflow.usflows2(label='usbyres with PctCR and PctCW added'); merge workflow.usbyres rsums(keep=CountyR CRTotals in=insums); by CountyR; PctCR=100*count/CRTotals; if countyW ne ' ' then do; set wsums(keep=countyw CWTotals) key=Countyw; if _iorc_ gt 0 then do; _msg=iorcmsg(); drop _msg; CWTotals=.; put countyw= _iorc_= _msg ; end; else PctCW=100*count/CWTotals; end; format CRTotals CWTotals comma7. PctCR PctCW 5.1; label CRTotals='Total work trips originating in CountyR' CWTotals='Total work trips ending in CountyW' PctCR='% of ALL trips originating in CountyR ending in CountyW' PctCW='% of ALL trips ending in CountyW originating in CountyR'; run; proc sort data=workflow.usflows2 (where=(pctcw ge .5 )) out=Wsort; by statew countyw descending count; run; ===========================End commented out================================ */ *----Generate reports, 1 per state, showing significant flows (at least .5 pct) for all counties. One report is sorted by residence geography, the other by work. -----; ods listing close; options nodate pageno=1; %macro doit(state,stab); %put Begin processing &statenm ; %let filename=%sysfunc(compress(&statenm)); ods html file="/pub/reports/workflow/&filename.Rsort.html" style=sasweb; ods pdf file="/pub/reports/workflow/&filename.Rsort.pdf" style=sasweb; title h=1 font=arial bold "Counts of Workers Commuting From &statenm Counties "; title2 h=1 bold "Each Flow Represents at Least .5% of All Trips Originating in the &statenm County"; title3 h=1 bold 'Sorted by Residence Geography'; proc print data=workflow.usflows2 noobs label ; where stater="&state"; where also PctCR ge .5 ; by areanamer notsorted crtotals; id AreanameR crtotals; label AreanameR='Work Flows From (CountyR)' AreanameW='Work Flows Into (CountyW)'; var areanameW count pctcr pctcw; format count comma9.; footnote1 h=1 font=arial "URL: https://mcdc.missouri.edu/reports/workflow/&statenm.Rsort.(html/pdf)"; footnote2 h=1 font=arial 'Note: Change "Rsort" to "Wsort" in URL to Get Companion Report Sorted by Work Geography'; footnote3 h=1 font=arial c=gray 'Report Produced by the Missouri State Census Data Center: mcdc.missouri.edu'; run; ods html close; ods pdf close; options pageno=1; ods html file="/pub/reports/workflow/&filename.Wsort.html" style=sasweb; ods pdf file="/pub/reports/workflow/&filename.Wsort.pdf" style=sasweb; title3 h=1 bold 'Sorted by Work Geography'; title h=1 font=arial bold "Counts of Workers Commuting Into &statenm Counties "; title2 h=1 bold "Each Flow Represents at Least .5% of All Trips Ending in the &statenm County"; title3 h=1 bold 'Sorted by Work Geography'; proc print data=Wsort noobs label; where statew="&state"; by areanamew notsorted cwtotals; id Areanamew cwtotals; label AreanameR='Work Flows From (CountyR)' AreanameW='Work Flows Into (CountyW)'; var areanamer count pctcw pctcr; format count comma9.; footnote1 h=1 font=arial "URL: https://mcdc.missouri.edu/reports/workflow/&statenm.Wsort.(html/pdf)"; footnote2 h=1 font=arial 'Note: Change "Wsort" to "Rsort" in URL to Get Companion Report Sorted by Residence Geography'; footnote3 h=1 font=arial c=gray 'Source: U.S. Bureau of the Census "Workflow" File Based on 2000 Census Long Form Data'; footnote4 h=1 font=arial c=gray 'Report Produced by the Missouri State Census Data Center: mcdc.missouri.edu'; run; ods html close; ods pdf close; %mend doit; %dostates(n=51,names=1) ;