x cd /pub/data/popests/Tools; %let pgm=dmig_report_states; filename pgm "&pgm..sas"; /*----Access the latest state level domestic and total migration data to provide an update to the Census Bureau report showing domestic migration trends by state. Jul, 2009: Running with 2008 data. Changed variables being reported. Now doing 2000-2005 and 2005-&year as intervals. Oct, 2010: Running with 2009 data. ------*/ %let year=2009; *<=================EDIT EACH TIME=============; %let yearp1=%eval(&year+1); %let yearm1=%eval(&year-1); %let yearm2=%eval(&year-2); %let yr=%substr(&year,3,2); %let yrm1=%substr(&yearm1,3,2); %let yrm2=%substr(&yearm2,3,2); libname popests "/pub/data/popests"; data dmigtrends; set popests.uscom&yr(where=(sumlev="040") keep=state areaname dmig: dommig sumlev); *---For consistency with Bureau report we ignore the quarter change from April to June 2000 and just look at annualized change from July 1 2000 to whatever year. ---; dmig0005_tot= sum(of dmig0001 dmig0102 dmig0203 dmig0304 dmig0405); dmig0005_avg= round( dmig0005_tot/5); label dmig0005_tot="Total Domestic Mig 7/1/00 to 7/1/05" dmig0005_avg="Avg Annual Domestic Mig 7/1/00 to 7/1/05"; dmig05&yr._tot= sum(of dmig0506 dmig0607 dmig0708 dmig0809); *<====add here===; dmig05&yr._avg= round( dmig05&yr._tot/ %eval(&yr-5)); label dmig05&yr._tot="Total Domestic Mig 7/1/05 to 7/1/&yr/" dmig05&yr._avg="Avg Annual Domestic Mig 7/1/05 to 7/1/&yr."; TrendChange=dmig&yrm1.&yr - dmig&yrm2&yrm1; *--compare the net domestic change in the most recent year with that of the previous year--; dmig00&yr._tot= dmig0005_tot + dmig&yrm1.&yr; dmig00&yr._avg=round( dmig00&yr._tot/&yr ); label dmig00&yr._tot="Total Domestic Migration 7/1/00 to 7/1/&yr" dmig00&yr._avg="Avg Annual Domestic Mig 7/1/00 to 7/1/&yr" TrendChange="Domestic Change Latest Yr - Previous Year"; keep state dmig0005_: dmig05&yr._: dmig&yrm1&yr dmig&yrm2&yrm1 TrendChange ; format dmig: comma10. TrendChange comma7.; format state $state.; run; proc rank data=dmigtrends descending out=popests.dmig_report_states(label="Report dataset for domestic migration report thru &year"); var dmig&yrm2.&yrm1. dmig&yrm1.&yr TrendChange dmig0005_tot dmig0005_avg dmig05&yr._tot dmig05&yr._avg; ranks Rankdmig&yrm2.&yrm1. Rankdmig&yrm1.&yr RankTrendChange Rankdmig0005_tot Rankdmig0005_avg Rankdmig05&yr._tot Rankdmig05&yr._avg; run; options ls=120 ps=60; title "Domestic Migration Trends by State"; title2 "Yearly and Average Yearly Changes"; proc print data=dmigtrends; var dmig0005_avg dmig&yrm2.&yrm1. dmig&yrm1.&yr. TrendChange dmig05&yr._avg dmig0005_tot dmig05&yr._tot; id state; run; proc print data=popests.dmig_report_states; title2 "Ranks Based on Yearly and Average Yearly Changes"; id state; var Rankdmig: RankTrend:; run; /* =======================Begin comment================ ======================End comment================== */ ods html file="/pub/data/popests/Reports/&pgm..html" (title="Domestic Migration by State") style=sasweb ; options pageno=1 ; title "Domestic Migration Trends for States"; title2 "Annual and Average Annual Domestic Migration Figures, 2000-&year"; proc report data=popests.&pgm nofs headskip headline style(column)=[foreground=black background=white font_face=helvetica font_size=2] style(lines)=[foreground=black background=lightgrey font_face=arial font_weight=bold font_size=2]; *---Adding the or condition 2-7-06 so that report contains a state summary line---; **where ®type="®code" or sumlev="040"; column State ("Annual Net Domestic Migration" dmig&yrm2.&yrm1. dmig&yrm1.&yr. TrendChange) ("Avg Annual Net Domestic Migration" dmig0005_avg dmig05&yr._avg) ("Total Net Domestic Migration" dmig0005_tot dmig05&yr._tot); define State / "State" display format=$state.; define dmig&yrm1.&yr. / "&yearm1.-&year" display format=comma9.; define dmig&yrm2.&yrm1. /"&yearm2.-&yearm1." display format=comma9.; define TrendChange / "Trend: This Year/ - Previous Year"; define dmig0005_avg / "2000-2005" display format=comma9.; define dmig05&yr._avg / "2005-&year." display format=comma9.; define dmig0005_tot / "2000-2005" display format=comma12.; define dmig05&yr._tot /"2005-&year." display format=comma12.; run; *-------------Repeat report for ranks--------------------------------------; title3 "Part 2: Rankings"; proc report data=popests.&pgm nofs headskip headline style(column)=[foreground=black background=white font_face=helvetica font_size=2] style(lines)=[foreground=black background=lightgrey font_face=arial font_weight=bold font_size=2]; *---Adding the or condition 2-7-06 so that report contains a state summary line---; **where ®type="®code" or sumlev="040"; column State ("Annual Net Domestic Migration" rankdmig&yrm2.&yrm1. rankdmig&yrm1.&yr. rankTrendChange) ("Avg Annual Net Domestic Migration" rankdmig0005_avg rankdmig05&yr._avg) ("Total Net Domestic Migration" rankdmig0005_tot rankdmig05&yr._tot); define State / "State" display format=$state.; define Rankdmig&yrm1.&yr. / "&yearm1.-&year" display format=comma9.; define Rankdmig&yrm2.&yrm1. /"&yearm2.-&yearm1." display format=comma9.; define RankTrendChange / "Trend: This Year/ - Previous Year"; define Rankdmig0005_avg / "2000-2005" display format=comma9.; define Rankdmig05&yr._avg / "2005-&year." display format=comma9.; define Rankdmig0005_tot /"2000-2005" display format=comma12.; define Rankdmig05&yr._tot /"2005-&year." display format=comma12.; compute after / style=[font_face=arial font_size=1 foreground=gray]; line " "; line "Source: U.S. Bureau of the Census, Federal State Coop for Population Estimates. State and county level estimates"; line " with components of change, 2000 to &year.. Released circa March, &yearp1"; line "Prepared by the University of Missouri Extension, Office of Social & Economic Data Analysis (OSEDA)"; line " under a contract with the Missouri Census Data Center"; line "Report generated on &sysdate9 by setup in popests/Tools/&pgm"; endcomp; run; ods html close; *** ods printer close;