*--------------------Step 4: Sample queries using SQL and Tabulate-----------------------------------------------*; proc sql; create table p3 as select r.race_id as race_id, g.geo_id as geo_id, sum(persons) as sumprsns, nraces, racelabl from pl94.&stab.detail d, pl94.race_ids r, pl94.&stab.geos (keep=geo_id areaname) g where g.geo_id=1 and d.geo_id = g.geo_id and d.race_id = r.race_id and voteage=1 group by g.geo_id, nraces, r.race_id, racelabl order by geo_id, nraces, r.race_id; quit; proc print data=p3; by nraces; id nraces; var racelabl sumprsns; sum sumprsns; format sumprsns comma9.; title2 'Sample Query: Reproduce Table P3 (Essentially) for California'; run; *---And now use proc tabulate to do some typical crosstabs of the basic data---*; proc sql; create view detailv as select * from pl94.cadetail d, pl94.race_ids r where geo_id le 2 and r.race_id=d.race_id ; quit; proc format; value geo 1='California' 2='Sacramento co.'; value yesno 1='Yes' 0='No'; value nraces 2-6='2 or more'; run; proc tabulate data=detailv; class white black asian geo_id hispanic voteage nraces; variable persons; format white black asian hispanic voteage yesno.; format nraces nraces. geo_id geo.; label geo_id='Area' nraces='# of Races'; table geo_id, all hispanic voteage, (all nraces*(white black asian))*persons=' '*(sum=' '*f=comma7. n*f=4.); title2 'Proc Tabulate Sample Report'; run; *--temp step to see if there are any blocks that split vtds-; proc sort data=pl94.&stab.geos(keep=sumlev county vtd tract block where=(sumlev='750')) nodupkey out=blksums(drop=sumlev); by county tract block; run cancel; *--this gave me the answer: there were no dups--; ===========================End commented out================================ */