x cd /pub/data/eeo2000/Tools; %let pgm=altviews; filename pgm "&pgm..sas"; *----(***** Experimental *****) We run this after cnvttbls setup. That job creates the input for this one - SAS datasets converted to the MCDC/OSEDA variable-naming and coding standards. In this job we create alternate views that involve breaking down the observation tables so that we have more rows and few columns. The idea is that it will sometimes be easier to select just the data you need by filtering rows. The columns are rather complex on some of the datasets - way too many cells. jgb, 12-03. <---Expanding ustable1 this way resulted in a dataset over 5 times larger than the original, even though we did not output zero cells. Not promising. ---*; title "Creating Alternative Views of Selected eeo2000 Tables - &pgm"; libname eeo2000 '/pub/data/eeo2000'; libname eeo (eeo2000); *<--alternate libref--; data altustable1; set eeo2000.ustable1(rename=(total=_Gtotal)); where _Gtotal > 0; length default=4; array t(12,2) t1i: ; array a (12) $7 _temporary_ ('White N','White H','Black N','Asian N','NHOPI N','AIAN N', 'BlackWN','AsianWN','AIAN WN','AIAN BN','OTHMR N','OTHER H'); drop t1i:; length race $6 hispanic $1 rhtype $1; label race='Race portion of Race/Ethnicity' rhtype='Race/Hispanic Summary type'; *--Values for rhtype are: '0' = total regardless of race or hispanic origin '1' = total hispanic '2' = Race/hispanic combination as per original table. --*; *--We do not keep an explicit male count but it can easily be derived as total-female --; rhtype='2'; do _i=1 to 12; race=a(_i); hispanic=substr(a(_i),7,1); Total=t(_i,1) + t(_i,2); Female=t(_i,2); label Total='Total employed by Race/Hispanic'; _total + total; _female+ female; if hispanic='H' then do; _htotal+total; _hfemale+female; end; link output; end; label Total='Total Workers' Female='Female Workers'; rhtype='1'; total=_htotal; female=_hfemale; hispanic='H'; race=' '; link output; hispanic='N'; total=_total - _htotal; female=_female - _hfemale; link output; rhtype='0'; total=_total; female=_female; hispanic=' '; race=' '; link output; return; output: if total then output; *<-----------only non-zero cells (counts)---------------------; return; drop _: socode csarea msapmsa; run; proc sort data=altustable1 out=eeo2000.altustable1(index=(state)); by State sumlev geocode rhtype hispanic; run; proc datasets library=eeo2000; modify altustable1; index create race; quit; *---test to see what comporess does--; data compressed(compress=yes); set; run cancel; *<===It INCREASED the size by 7 pct!===; %include '/pub/data/eeo2000/Tools/eeo_industry.sas'; *<-------Include this code to define $eeo_ind format code which provides descriptions for the 88 industry categories used in Table 23. -----; data altustable23; set eeo2000.table23 (rename=(total=_Gtotal sumlevel=SumLev)); where _Gtotal > 0; length default=4; array t(12,2,88) t23cell: ; array a (12) $7 _temporary_ ('White N','White H','Black N','Asian N','NHOPI N','AIAN N', 'BlackWN','AsianWN','AIAN WN','AIAN BN','OTHMR N','OTHER H'); drop t23cell:; length race $6 hispanic $1 rhtype $1 Industry $2; label race='Race portion of Race/Ethnicity' rhtype='Race/Hispanic Summary type'; *--Values for rhtype are: '0' = total regardless of race or hispanic origin '1' = total hispanic '2' = Race/hispanic combination as per original table. --*; *--We do not keep an explicit male count but it can easily be derived as total-female --; GeoName=geocode; format GeoName $eeogeo.; do _Ind=1 to 88; Industry=put(_ind,z2.); *<--convert the numeric index to a 2-char code with leading zeroes--; rhtype='2'; _total=0; _female=0; _htotal=0; _hfemale=0; do _i=1 to 12; race=a(_i); hispanic=substr(a(_i),7,1); Total=t(_i,1,_Ind) + t(_i,2,_Ind); Female=t(_i,2,_Ind); label Total='Total employed by Race/Hispanic/Industry'; _total + total; _female+ female; if hispanic='H' then do; _htotal+total; _hfemale+female; end; link output; end; rhtype='1'; total=_htotal; female=_hfemale; hispanic='H'; race=' '; link output; hispanic='N'; total=_total - _htotal; female=_female - _hfemale; link output; rhtype='0'; total=_total; female=_female; hispanic=' '; race=' '; link output; end; *___ _Ind loop--; label Total='Total Workers' Female='Female Workers'; return; output: if total then output; *<-----------only non-zero cells (counts)---------------------; return; drop _: socode workplace; format industry eeo_ind.; run; proc sort data=altustable23 out=eeo2000.altustable23(index=(workstate)); by WorkState sumlev geocode industry rhtype hispanic; run; proc tabulate missing data=eeo.altustable23(where=(workstate in (' ','29'))) ; by workstate; class sumlev race hispanic cenocc rhtype Industry geocode; format cenocc $cenocc32. Industry $eeo_ind32. geocode $eeogeo32.; var total female; table rhtype, (total female)*(sum*f=comma12. n*f=comma7.); table rhtype*(geocode sumlev race hispanic cenocc Industry),(total female)*(sum*f=comma12. n*f=comma7.); run ; proc print data=eeo2000.altustable23(obs=100); by workstate; id geocode geoname; title2 "eeo2000.altustable23"; run; %include sascode(notify);