data sasuser.val; input value r1 r2; valuen = (r1+r2)/2.0; keep value valuen; cards; 01 0 10000 02 10000 14999 03 15000 19999 04 20000 24999 05 25000 29999 06 30000 34999 07 35000 39999 08 40000 49999 09 50000 59999 10 60000 69999 11 70000 79999 12 80000 89999 13 90000 99999 14 100000 124999 15 125000 149999 16 150000 174999 17 175000 199999 18 200000 249999 19 250000 299999 20 300000 399999 21 400000 499999 22 500000 749999 23 750000 999999 24 1000000 1000000 ; run; proc sort data=sasuser.val; by value; run; data state; set sasuser.g1newrh sasuser.Gnj; lhinc = log(5000+hinc); run; proc sort data=state; by value; data state; merge state sasuser.val; by value; run; proc sort; by state; proc univariate freq data=state noprint; var lhinc; by state; output out=a PCTLPRE=p PCTLPTS=1 2 3 4 5 7 10 20 30 40 50 60 70 80 90 93 95 96 97 98 99; run; proc transpose data=a out=b; run; data b; set b ; if _N_> 1;run; /* 2. Now lets do the state statistics*/ data stateNJ; set state; if state=34; run; proc sort data=stateNJ; by puma1; data faminc; set stateNJ; if hht=1 or hht=2 or hht=3; run; proc means median data=faminc noprint; var finc; weight hweight; by puma1; output out=c median=med; run; data c; set c; keep puma1 med; run; data stateNJ; merge stateNJ c; by puma1; data stateNJ; set stateNJ; m4 = med*0.8; /* if m4 > 50200 then m4 = 50200; */ hlinc = 0; units=1; if persons <= 4 and hinc < m4*(1-(4-persons)*0.1) then hlinc = 1; if persons > 4 and hinc < m4*(1+(persons-4)*0.08) then hlinc = 1; /*************** * This calculates the percentage of households * below the 80pct of median ******************/ /* Crowded */ uncrowd = 0; if persons <= rooms then uncrowd = 1; /* new construction */ new = 0; if yrbuilt=1 or yrbuilt=2 or yrbuilt=3 then new =1; /* Affordable */ Aff = 0; if smocapi > 0 then grapi=.; if grapi > 0 then smocapi=.; if smocapi ne . and smocapi <= 30 then Aff=1; if grapi ne . and grapi <= 30 then Aff=1; xnum = Aff*uncrowd*new*hlinc; enum = Aff*new*hlinc; cnum = uncrowd*new*hlinc; denom = new; denom2 = new*hlinc; tot = 1; run; proc means data=stateNJ noprint; var denom denom2 xnum enum cnum hlinc tot; by puma1; weight hweight; output out = res sum= sdenom sdenom2 snum senum scnum slinc stot; run; data res; set res; rat = snum/sdenom; rat2 = snum/sdenom2; rat3 = slinc/stot; state = 'NJ'; keep puma1 state snum senum scnum sdenom sdenom2 slinc stot rat rat2 rat3; run; proc print; run; data sasuser.ownerNJ; set stateNJ; if smocapi > 0 and smocapi <= 99 and hlinc=1; lhinc = log(1+hinc); sm = log( smocapi+2/(102-smocapi)); edug = 0; if educ >7 then edug = 1; if new = 1; run; data sasuser.rentalNJ; set stateNJ; if grapi>0 and grapi <= 99 and hlinc=1; lhinc = log(1+hinc); gra = log( (grapi+2)/(102-grapi)); edug = 0; if educ >7 then edug = 1; if new = 1; run; proc reg data= sasuser.rentalNJ; weight hweight; model gra= persons uncrowd sex age grent EDUG rooms bldgsz VEHICL lhinc; output out=d cookd=cd p=p r =r; run; proc gplot data=d; plot cd*r r*p; run; proc univariate freq; var grent lhinc; run; data sasuser.rentalNJ; set sasuser.rentalNJ; renth = 0; if grent > 839 then renth =1; hinch = 0; if lhinc > 10.05 then hinch =1; run; proc reg data= sasuser.rentalNJ; weight hweight; model gra= persons uncrowd sex age renth EDUG rooms bldgsz VEHICL hinch ; output out=d cookd=cd p=p r =r; run; proc gplot data=d; plot cd*r r*p; run; proc logistic data= sasuser.rentalNJ; weight hweight; model Aff = persons uncrowd sex age renth EDUG rooms bldgsz VEHICL hinch; run;