/* SAS Code to create graphs based on 2000 Census Race data*/ /* If you have questions, please contact: Xanthippe Stevens Information Specialist The University of Kansas Policy Research Institute 1541 Lilac Lane, Suite 607 Lawrence, KS 66044 (785) 864-9111 xan@ku.edu */ libname data 'c:/data/census/2000/'; %macro mymacro(geo=20); filename GIF1 "c:\web\ksdata\census\2000\race\gif\AP&geo.big.gif"; /* Asian/Pacific Islander */ filename GIF2 "c:\web\ksdata\census\2000\race\gif\AI&geo.big.gif"; /* American Indian/Native Alaskan */ filename GIF3 "c:\web\ksdata\census\2000\race\gif\AF&geo.big.gif"; /* African-American */ filename GIF4 "c:\web\ksdata\census\2000\race\gif\O&geo.big.gif"; /* Other */ data geocode; set data.geocodes; where geocode=&geo.; run; data race00; set data.race00 data.race8090; /*data sets containing 1980, 1990, & 2000 data*/ where geocode=&geo and v_name<>"TOTPOP" and v_name<>"WHITE" and v_name<>"PALW" and v_name<>"PAYW" and v_name<>"SPANISH"; output; retain val; drop val; if v_name="PAYA" and v_year=2000 then val=v_value; if v_name="PAYP" and v_year=2000 then do; val=val+v_value; v_name="PAYAP"; v_year=2000; v_value=val; geocode=&geo.; output; end; run; proc sql; /*Need maximum value in order set scale on graphs*/ select max(v_value), max(v_value)/4 into :maxval, :scale from race00; select (geo_desc) into :geoname from geocode; quit; /*################### FIRST RACIAL GROUP - ASIAN/PACIFIC ISLANDER #####################*/ /*This section makes tables of asian and pacific islander data then plots the data on a county level. This group is slightly different than the rest as we had to aggregate asian population with hawaiian and other pacific islander for these totals. */ data racea; set race00; where v_name="ASIAN" or v_name="PAYA" or v_name="PALA" or v_name="PAYP" or v_name="PALP"; run; proc sort data=racea; by geocode v_year v_name; run; data hilo; set racea; retain val val2; drop val val2; length hi 8 lo 8; select (v_year); when (1980) do; if v_name="ASIAN" then do; hi=v_value; lo=v_value-(&maxval./1000); output; end; end; when (1990) do; if v_name="ASIAN" then do; hi=v_value; lo=v_value-(&maxval./1000); output; end; end; when (2000) do; if v_name="PALA" then val=v_value; if v_name="PALP" then val=val+v_value; if v_name="PAYA" then val2=v_value; if v_name="PAYP" then do; hi=val2+v_value; lo=val; output; end; end; otherwise; end; run; goptions reset=global gunit=pct border cback=white device=gif733 gsfname=GIF1 /*We generated two sizes of graphs. The next line which is commented out is for the smaller thumbnail size graphs*/ /*hsize=1.5 vsize=1.5*/ colors=(black blue green red) ftext=swissb htitle=4 htext=5; title1 'Total Asian Population'; title2 &geoname.; footnote 'Source: U.S. Census Bureau'; symbol1 color=blue interpol=join value=dot height=1; symbol2 color=blue interpol=join value=dot height=1; axis1 order=(1980 to 2000 by 10) label=none major=(height=2) minor=(number=4 height=1) offset=(2,2); axis2 order=(0 to &maxval. by &scale.) label=none major=(height=1.5) offset=(0,0) minor=(number=1 height=1); pattern1 color=white value=msolid; pattern2 color=blue value=msolid; /*plotting the low number using a colid white pattern over the high number creates the pie shaped wedge indicating the range in population for 2000.*/ proc gplot data=hilo; plot lo*v_year hi*v_year / overlay areas=2 haxis=axis1 vaxis=axis2; run; /*################################ NEXT RACIAL GROUPING ##############################*/ /*This section makes tables of native american and eskimo data then plots the data on a county level*/ data racena; set race00; where v_name="INDIAN" or v_name="PAYI" or v_name="PALI"; run; proc sort data=racena; by geocode v_year v_name; run; data hilo; set racena; retain val; drop val; length hi 8 lo 8; select (v_year); when (1980) do; if v_name="INDIAN" then do; hi=v_value; lo=v_value-(&maxval./1000); output; end; end; when (1990) do; if v_name="INDIAN" then do; hi=v_value; lo=v_value-(&maxval./1000); output; end; end; when (2000) do; if v_name="PALI" then val=v_value; if v_name="PAYI" then do; hi=v_value; lo=val; output; end; end; otherwise; end; run; goptions reset=global gunit=pct border cback=white device=gif733 gsfname=GIF2 /* hsize=1.5 vsize=1.5*/ colors=(black blue green red) ftext=swissb htitle=4 htext=5; title1 'Total American Indian or Alaskan Native Population'; title2 &geoname; footnote 'Source: U.S. Census Bureau'; symbol1 color=blue interpol=join value=dot height=1; symbol2 color=blue interpol=join value=dot height=1; axis1 order=(1980 to 2000 by 10) label=none major=(height=2) minor=(number=4 height=1) offset=(2,2) ; axis2 order=(0 to &maxval. by &scale.) label=none major=(height=1.5) offset=(0,0) minor=(number=1 height=1); pattern1 color=white value=msolid; pattern2 color=blue value=msolid; proc gplot data=hilo; plot lo*v_year hi*v_year / overlay areas=2 haxis=axis1 vaxis=axis2; run; /*################################ NEXT RACIAL GROUPING ##############################*/ /*This section makes tables of black and african-american data then plots the data on a county level*/ data raceb; set race00; where v_name="BLACK" or v_name="PAYB" or v_name="PALB"; run; proc sort data=raceb; by geocode v_year v_name; run; data hilo; set raceb; retain val; drop val; length hi 8 lo 8; select (v_year); when (1980) do; if v_name="BLACK" then do; hi=v_value; lo=v_value-(&maxval./1000); output; end; end; when (1990) do; if v_name="BLACK" then do; hi=v_value; lo=v_value-(&maxval./1000); output; end; end; when (2000) do; if v_name="PALB" then val=v_value; if v_name="PAYB" then do; hi=v_value; lo=val; output; end; end; otherwise; end; run; goptions reset=global gunit=pct border cback=white device=gif733 gsfname=GIF3 /*hsize=1.5 vsize=1.5*/ colors=(black blue green red) ftext=swissb htitle=4 htext=5; title1 'Total Black or African-American Population'; title2 &geoname; footnote 'Source: U.S. Census Bureau'; symbol1 color=blue interpol=join value=dot height=1; symbol2 color=blue interpol=join value=dot height=1; axis1 order=(1980 to 2000 by 10) label=none major=(height=2) minor=(number=4 height=1) offset=(2,2); axis2 order=(0 to &maxval. by &scale.) label=none major=(height=1.5) offset=(0,0) minor=(number=1 height=1); pattern1 color=white value=msolid; pattern2 color=blue value=msolid; proc gplot data=hilo; plot lo*v_year hi*v_year / overlay areas=2 haxis=axis1 vaxis=axis2; run; /*################################ NEXT RACIAL GROUPING ##############################*/ /*This section makes tables of other racial data then plots the data on a county level*/ data raceo; set race00; where v_name="OTHER" or v_name="PAYO" or v_name="PALO"; run; proc sort data=raceo; by geocode v_year v_name; run; data hilo; set raceo; retain val; drop val; length hi 8 lo 8; select (v_year); when (1980) do; if v_name="OTHER" then do; hi=v_value; lo=v_value-(&maxval./1000); output; end; end; when (1990) do; if v_name="OTHER" then do; hi=v_value; lo=v_value-(&maxval./1000); output; end; end; when (2000) do; if v_name="PALO" then val=v_value; if v_name="PAYO" then do; hi=v_value; lo=val; output; end; end; otherwise; end; run; goptions reset=global gunit=pct border cback=white device=gif733 gsfname=GIF4 /*hsize=1.5 vsize=1.5*/ colors=(black blue green red) ftext=swissb htitle=4 htext=5; title1 'Total Population Reporting Other Race'; title2 &geoname; footnote 'Source: U.S. Census Bureau'; symbol1 color=blue interpol=join value=dot height=1; symbol2 color=blue interpol=join value=dot height=1; axis1 order=(1980 to 2000 by 10) label=none major=(height=2) minor=(number=4 height=1) offset=(2,2); axis2 order=(0 to &maxval. by &scale.) label=none major=(height=1.5) offset=(0,0) minor=(number=1 height=1); pattern1 color=white value=msolid; pattern2 color=blue value=msolid; proc gplot data=hilo; plot lo*v_year hi*v_year / overlay areas=2 haxis=axis1 vaxis=axis2; run; quit; %mend; /* This macro sends the geocode of each county to the code above. This is a convenient way to generate the four graphs need for each of 105 counties in Kansas */ %macro runall; %do ccode=20001 %TO 20209 %by 2; %mymacro(geo=&ccode); %end; %mend; %runall