%let name=usa_jobs_timeline; filename odsout '.'; /* SAS imitation of: http://www.npr.org/sections/money/2015/05/18/404991483/how-machines-destroy-and-create-jobs-in-4-graphs http://apps.npr.org/dailygraphics/graphics/streamgraph/child.html?initialWidth=900;childId=responsive-embed-streamgraph */ data jobs_data; format number_of_jobs comma15.0; informat number_of_jobs comma15.0; input year number_of_jobs job_title $ 17-80; cards; 1850 2,634,726 Farming 1860 3,547,108 Farming 1870 5,481,918 Farming 1880 6,951,889 Farming 1890 . Farming 1900 9,377,318 Farming 1910 10,575,708 Farming 1920 8,999,996 Farming 1930 9,965,799 Farming 1940 8,137,671 Farming 1950 6,715,837 Farming 1960 3,841,636 Farming 1970 2,367,000 Farming 1980 2,170,980 Farming 1990 1,834,586 Farming 2000 1,596,133 Farming 2010 1,550,825 Farming 1850 1,893,868 Blue Collar 1860 2,820,708 Blue Collar 1870 3,763,654 Blue Collar 1880 5,750,884 Blue Collar 1890 . Blue Collar 1900 9,795,841 Blue Collar 1910 13,180,004 Blue Collar 1920 15,293,734 Blue Collar 1930 17,563,251 Blue Collar 1940 17,518,024 Blue Collar 1950 21,597,798 Blue Collar 1960 22,213,847 Blue Collar 1970 25,365,400 Blue Collar 1980 29,353,560 Blue Collar 1990 29,745,628 Blue Collar 2000 30,299,914 Blue Collar 2010 27,774,198 Blue Collar 1850 0 Service 1860 734,199 Service 1870 1,001,739 Service 1880 1,362,457 Service 1890 . Service 1900 2,516,481 Service 1910 3,425,103 Service 1920 3,210,240 Service 1930 4,626,902 Service 1940 5,384,412 Service 1950 5,758,782 Service 1960 6,780,649 Service 1970 9,343,300 Service 1980 12,267,680 Service 1990 14,893,651 Service 2000 16,625,420 Service 2010 21,581,676 Service 1850 526,185 White Collar 1860 958,406 White Collar 1870 1,330,995 White Collar 1880 2,127,372 White Collar 1890 . White Collar 1900 4,929,100 White Collar 1910 7,554,213 White Collar 1920 10,117,443 White Collar 1930 14,113,760 White Collar 1940 14,716,785 White Collar 1950 21,117,601 White Collar 1960 25,842,352 White Collar 1970 36,335,200 White Collar 1980 51,383,060 White Collar 1990 65,815,396 White Collar 2000 78,988,340 White Collar 2010 85,712,455 White Collar 1850 116,778 Other 1860 251,177 Other 1870 266,672 Other 1880 309,561 Other 1890 . Other 1900 826,977 Other 1910 1,518,450 Other 1920 1,637,201 Other 1930 1,589,839 Other 1940 1,091,549 Other 1950 2,127,484 Other 1960 2,045,847 Other 1970 2,850,600 Other 1980 2,174,680 Other 1990 3,055,502 Other 2000 2,199,069 Other 2010 2,483,525 Other ; run; proc sql noprint; create table jobs_data as select unique jobs_data.*, sum(number_of_jobs) as total_jobs_year from jobs_data group by year; quit; run; data jobs_data; set jobs_data; format percent_of_jobs percent7.0; percent_of_jobs=(number_of_jobs/total_jobs_year); run; data jobs_data; set jobs_data; stacking_order=99; if job_title='Service' then stacking_order=1; if job_title='Farming' then stacking_order=2; if job_title='White Collar' then stacking_order=3; if job_title='Blue Collar' then stacking_order=4; if job_title='Other' then stacking_order=5; length html_percent html_number $300; html_percent= 'title='||quote( 'In '||trim(left(year))||'0d'x|| trim(left(put(percent_of_jobs,percent7.1)))||' of workers were in'||'0d'x|| trim(left(job_title))||' jobs.'); run; proc sql noprint; create table control as select unique stacking_order as start, job_title as label from jobs_data; quit; run; data control; set control; fmtname='stkfmt'; type='N'; run; proc format lib=work cntlin=control; run; goptions device=png; goptions noborder; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="USA Jobs Timeline") style=htmlblue; goptions gunit=pct htitle=4.0 htext=2.0 ftitle='albany amt/bold' ftext='albany amt'; goptions ctext=gray33; %let c_serv=cxe5d97f; %let c_farm=cx3eb18b; %let c_whit=cxe36ca5; %let c_blue=cx45a5ec; %let c_othr=cxd6d6d6; pattern1 v=s c=&c_serv; pattern2 v=s c=&c_farm; pattern3 v=s c=&c_whit; pattern4 v=s c=&c_blue; pattern5 v=s c=&c_othr; axis1 label=none minor=none style=0 offset=(0,0); axis2 label=none order=(1850 to 2010 by 10); legend1 position=(right middle) across=1 label=none order=descending value=(justify=left) shape=bar(.15in,.15in) offset=(-2,0); title1 ls=1.5 "How Jobs in the United States Shifted, over 150 Years"; footnote1 j=l move=(+5,+0) link='http://apps.npr.org/dailygraphics/graphics/streamgraph/child.html?initialWidth=700' c=gray "Data source: IPUMS-USA, University of Minnesota (via NPR's graph)"; footnote2 j=l move=(+5,+0) c=&c_whit "White collar" c=gray " includes professional, technical, managerial, sales, and clerical jobs."; footnote3 j=l move=(+5,+0) c=&c_blue "Blue collar" c=gray " includes machine operators, assembly, manual labor, and construction jobs."; footnote4 j=l move=(+5,+0) ls=1.0 c=&c_serv "Service" c=gray " includes food service, health care, and personal service jobs."; proc gchart data=jobs_data; format stacking_order stkfmt.; vbar year / discrete missing type=sum sumvar=percent_of_jobs subgroup=stacking_order raxis=axis1 maxis=axis2 space=0 width=5 coutline=gray77 autoref frontref lref=33 cref=gray55 legend=legend1 html=html_percent des='' name="&name"; run; /* proc gchart data=jobs_data; format stacking_order stkfmt.; vbar year / discrete missing type=sum sumvar=number_of_jobs subgroup=stacking_order raxis=axis1 maxis=axis2 noframe space=0 width=5 coutline=gray77 autoref frontref lref=33 cref=gray55 legend=legend1 des='' name="&name"; run; */ proc sort data=jobs_data out=jobs_data; by job_title year; run; data anno_labels; set jobs_data; xsys='2'; ysys='2'; hsys='3'; when='a'; x=year; y=percent_of_jobs; function='label'; text=trim(left(job_title)); if job_title='Farming' and year=1870 then do; position='2'; color="&c_farm"; output; end; if job_title='Blue Collar' and year=1980 then do; position='3'; color="&c_blue"; output; end; if job_title='Service' and year=1980 then do; position='2'; color="&c_serv"; output; end; if job_title='White Collar' and year=1980 then do; position='1'; color="&c_whit"; output; end; if job_title='Other' and year=1940 then do; position='2'; color="&c_othr"; output; end; run; symbol1 value=dot height=2.0 interpol=join c=&c_blue; symbol2 value=dot height=2.0 interpol=join c=&c_farm; symbol3 value=dot height=2.0 interpol=join c=&c_othr; symbol4 value=dot height=2.0 interpol=join c=&c_serv; symbol5 value=dot height=2.0 interpol=join c=&c_whit; axis3 label=none major=none minor=none style=0 offset=(0,0); axis4 label=none minor=none; legend2 label=none position=top repeat=2; ods html anchor='line'; proc gplot data=jobs_data anno=anno_labels; plot percent_of_jobs*year=job_title / vaxis=axis3 haxis=axis4 noframe autovref cvref=gray77 lvref=33 legend=legend2 html=html_percent des='' name="&name._line"; run; quit; ODS HTML CLOSE; ODS LISTING;