x cd /pub/data/pums2000/Tools; %let pgm=meric_entre_extracts; filename pgm "&pgm..sas"; *---Generate custom extracts having to do with entrepreneurs for the MERIC Entrepreneur web application project. Summer, 2005. JGB, IG OSEDA. Rerun 10-25-05 to change meaning of entre codes 1 and 2 since they were assumed to be the opposite of how we orginally coded them. ----*; libname pums2000 '/pub/data/census_2000/pums2000' access=readonly; libname user '/SAS_temp/user'; libname meric '/pub/data/pums2000/meric'; title "&pgm : Generate Data for MERIC Entrepreneur Web Application"; %*let mopuma=mo; %*let mopuma=mopuma; proc printto print="&pgm..mopuma.lst" new; run; proc format library=library; *--ran interactively. Requires autoexec that allocates library for write access, which normally means jgb only-----------------------------------------------; %include '/pub/sas/formats/Smopuma.sas'; *<---edited specifically for this project---; run cancel; proc format; *----Assign value labels to codes in the data set-----; value povcat 0 = 'Below poverty' 100 = '100 to 199 pct of poverty' 200 = '200 to 299 pct of poverty' 300 = '300 to 399 pct of povery' 400 = '400 to 499 pct of poverty' 500 = '500 pct of poverty or more'; value entrecat 0='Not an entrepreneur' 1='Full time' 2='Part time' 3='Trivial' 9='Total'; value ind 11="Agriculture, Forestry, Fishing and Hunting" 21-22="Mining and Utilities" 23="Construction" 31-33="Manufacturing" 42="Wholesale Trade" 44-45="Retail Trade" 48-49="Transportation and Warehousing" 51-53="Information, Finance, and Real Estate" 54="Professional and Technical Services" 55="Management of Companies and Enterprises" 56="Administrative and Waste Services" 61="Educational Services" 62="Health Care and Social Assistance" 71="Arts, Entertainment, and Recreation" 72="Accommodations and Food Services" 81="Other Services Except Public Administration" 92='Government or Military' 99='Unemployed' ; value soc 11="Management Occupations" 13="Business and Financial Operations Occupations" 15="Computer and Mathematical Occupations" 17="Architecture and Engineering Occupations" 19="Life, Physical, and Social Science Occupations" 21="Community and Social Services Occupations" 23="Legal Occupations" 25="Education, Training, and Library Occupations" 27="Arts, Design, Entertainment, Sports, and Media Occupations" 29="Healthcare Practitioners and Technical Occupations" 31="Healthcare Support Occupations" 33="Protective Service Occupations" 35="Food Preparation and Serving Related Occupations" 37="Building & Grounds Cleaning & Maintenance Occupations" 39="Personal Care and Service Occupations" 41="Sales and Related Occupations" 43="Office and Administrative Support Occupations" 45="Farming, Fishing, and Forestry Occupations" 47="Construction and Extraction Occupations" 49="Installation, Maintenance, and Repair Occupations" 51="Production Occupations" 53="Transportation and Material Moving Occupations" 55="Unemployed or Military"; Value $educat '01'='No formal education' '02'='Nursery school to 4th grade' '03'='5th to 8th grade' '04'='7th or 8th grade' '05'='9th to 11th grade' '08'='12th grade, no diploma' '09'='High school graduate' '10'='Some college, no degree' '12'='Associate''s degree' '13'='Bachelor''s degree' '14'='Master''s degree' '15'='Professional degree' '16'='Doctorate' ; Value $sex '1'='Male' '2'='Female'; run; %macro doit(mopuma); data xtract; set pums2000.moprecs5 ; ***(keep=puma5 pweight poverty clwkr incws incse inctot age); where (poverty ne 0 and age >= 18 and pweight gt 0); *<===============Universe filter====================; %if &mopuma=mo %then %do; puma5='29000'; %end; length entrecat povcat 3 ; entrecat = 0; if clwkr in ('6','7') then entrecat=2; *---initially they are part-time self-employed--; if abs(incse) gt 0 then do; if IncTot=0 then PctIncSE=50; else PctIncSE=100*abs(incse)/abs(IncTot); *<---absolute values are to handle income loss situations--; if PctIncSE ge 50 then entrecat=1; else if entrecat=0 and PctIncSE >=20 then entrecat=2; end; else if abs(IncTot) then PctIncSE=0; povcat = int(poverty/100)*100; *---round it to 100s digit times 100. hdu become h00 --; length educat $2; select(educ); when('04') educat='03'; when('06','07') educat='05'; when ('11') educat='10'; otherwise educat=educ; end; if white='0' then WhiteAC=0; else whiteAC=pweight; if black='0' then BlackAC=0; else blackAC=pweight; if asian='0' then AsianAC=0; else asianAC=pweight; if aian='0' then AianAC=0; else aianAC=pweight; if hispan='01' then Hispanic=0; else Hispanic=pweight; Males=0; Females=0; if sex='1' then Males=pweight; else Females=pweight; *---to simplify the aggregation process with proc means we output extra observations for the pseudo-entrecat category of 9, total---; if entrecat ne 0 then output; entrecat=9; output; label entrecat='Entrepreneurial Category' ; label pweight='Persons'; keep puma5 pweight entrecat povcat poverty clwkr incws incse inctot age educat sex ; keep whiteAC blackAC asianAC aianAC hispanic Males Females; keep indNAICS occsoc5; *---industry and occupation codes---; run; proc sort data=xtract; by puma5; run; proc means data=xtract noprint; by puma5; class povcat educat entrecat; types entrecat*(povcat educat); var pweight; output out=meansout sum=Persons; run; proc means data=xtract noprint; by puma5; class entrecat; types entrecat; var pweight Males Females whiteAC blackAC asianAC aianAC hispanic; output out=meansout2(rename=(pweight=TotPop)) sum=; run; proc means data=xtract noprint; by puma5; weight pweight; class entrecat; types entrecat; var poverty incws incse inctot ; output out=meansout3 mean=MeanPovRatio AvgIncWS AvgIncSE AvgIncTot; run; data meric.&mopuma.sums1(label="Overall characteristics by &mopuma and Entrepreneur Category"); merge meansout2 meansout3; by puma5 entrecat; drop _freq_ _type_; run; proc print data=meric.&mopuma.sums1 label; by puma5; id entrecat; title2 "meric.&mopuma.sums1"; run; proc sort data=meansout; by puma5 entrecat; run; data &mopuma.sums2 ; merge meansout (in=in1) meansout2(keep=puma5 entrecat TotPop in=in2); by puma5 entrecat; if not (in1 and in2) then do; _nerr+1; if _nerr gt 5 then abort abend; put / _all_; end; length Pct 4; format pct 5.1; if TotPop then Pct=100*Persons/TotPop; length rowcat $32; if _type_=5 then do; Table='pov'; RowCat=put(povcat,povcat.); end; else do; Table='edu'; RowCat=put(educat,$educat.); end; drop _: ; run; proc sort data=&mopuma.sums2 out=meric.&mopuma.sums2(label="Poverty and Education levels by &mopuma & Entrepreneur Category" index=(puma5)); by puma5 Table povcat educat entrecat; run; proc print data=meric.&mopuma.sums2(obs=200); by puma5; id table rowcat; title2 "meric.&mopuma.sums2"; run; *--------------now build the summary datasets by occupation and industry.--------------*; options fmtsearch=(pums2000.formats sasctlgs.formats formats); data meansin; set xtract(keep=pweight puma5 occsoc5 indNaics entrecat incWS incSE incTot ); length ind soc 8; indNaics=left(indnaics); if indnaics=:'3M' then ind=33; else if indnaics=:'4M' then ind=45; else ind=substr(indnaics,1,2); if ind=0 then ind=.; if incTot=. then incTot=0; *<---just to make sure we get correct Ns--; soc=substr(occsoc5,1,2); if soc=0 then soc=.; %if &mopuma=mo %then %do; puma5='29000'; %end; label ind='Industry' soc='Occupation'; run; proc sort; by entrecat; run; proc means data=meansin noprint nway; freq pweight; *here entrecat=9; by entrecat; class puma5 ind; format ind ind.; ** soc soc.; var incWS incSE incTot; output out=meric.&mopuma.means_ind(drop=_type_ _freq_ ) n(incTot)=Nindustry mean= ; run; proc means data=meansin noprint nway; freq pweight; *here entrecat=9; by entrecat; class puma5 soc; format soc soc.; var incWS incSE incTot; output out=meric.&mopuma.means_soc(drop=_type_ _freq_ ) n(incTot)=Noccupation mean= ; run; *---fix the labels for the 2 means output datasets---*; proc datasets nolist library=meric; modify &mopuma.means_ind; label incWS="Avg Wage & Salary Income" incSE="Avg Self-Employment Income" incTot="Avg Total Income" Nindustry='# Persons in Industry'; modify &mopuma.means_soc; label incWS="Avg Wage & Salary Income" incSE="Avg Self-Employment Income" incTot="Avg Total Income" Noccupation='# Persons in Occupation'; quit; proc print data=meric.&mopuma.means_ind label; title2 "meric.&mopuma.sums_ind"; by entrecat puma5; id ind; format ind ind. puma5 $mopuma. ; format inc: dollar9.; format entrecat entrecat.; run; proc print data=meric.&mopuma.means_soc label; title2 "meric.&mopuma.sums_soc"; by entrecat puma5; id soc; format soc soc. puma5 $mopuma. ; format inc: dollar9.; format entrecat entrecat.; run; %mend doit; %doit(mopuma); options mprint; %doit(mo);