Advertisement
Guest User

Untitled

a guest
Nov 26th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 3.19 KB | None | 0 0
  1. /* NEW JERSEY */
  2.  
  3. /* CALCULATE PROPORTION OF LOW INCOME FAMILIES */
  4.  
  5. /* Get data with households that house a single family --change set */
  6. DATA singlefamilyhht;
  7. SET project.gnj;
  8. IF hht=1 or hht=2 or hht=3;
  9. run;
  10.  
  11. /* THIS IS TO GET THE COUNTS FOR PUMA1 -- NOTHING TO CHANGE, JUST GET THE "TOTAL" FOR YOUR PUMA1*/
  12. proc sql;
  13. select puma1, count(*) as N_Obs
  14. from singlefamilyhht
  15. group by puma1;
  16. quit;
  17.  
  18. /* 34011 TOTAL : 9558 */
  19.  
  20. /*median of single family household*/
  21. PROC MEANS data=singlefamilyhht(where=(persons=4)) median noprint;
  22. class puma1;
  23. var hinc;
  24. weight hweight;
  25. output out = test median= med;
  26. run;
  27. proc print data=test;
  28. run;
  29.  
  30. /* ALL OF THE MEDIANS
  31. 11 61000.00
  32. 12 68000.00
  33. 20 68400.00
  34. 30 88000.00
  35. 41 77400.00
  36. 42 84040.00
  37. 50 103000.00
  38. 60 65400.00
  39. 70 47800.00
  40. 80 75000.00
  41. 90 92000.00
  42. 101 80000.00
  43. 102 99000.00
  44. 110 64400.00
  45. 120 79300.00
  46. */
  47.  
  48. /*Get count of low income households based on listed conditions -- CHANGE THE PUMA1 AND THE MEDIAN*/
  49. proc sql;
  50. select count(*) as N_Obs
  51. from singlefamilyhht
  52. where puma1=34011
  53. and
  54. (persons=4 and hinc<.8*(61000)
  55. or
  56. persons=3 and hinc< .9*(.8*(61000))
  57. or
  58.  persons=2 and hinc< .8*(.8*(61000))
  59. or
  60.  persons=5 and hinc< 1.08*(.8*(61000))
  61. or
  62. persons=6 and hinc< 1.16*(.8*(61000)))
  63. ;
  64. quit;
  65.  
  66. /* 34011: N_Obs =3536*/
  67.  
  68. /* 34011 Proportion : 3536/9558 = .36995 */
  69.  
  70.  
  71. /* CALCULATE PROPORTION OF LOW INCOME, AFFORDABLE, AND NOT CROWDED AMONG NEW UNITS  */
  72.  
  73. /* gives data for new units --  change set */
  74. DATA newunits;
  75. SET project.gnj;
  76. IF yrbuilt=1
  77. or
  78. yrbuilt=2
  79. or
  80. yrbuilt=3;
  81. run;
  82.  
  83. /*GIVES TOTAL COUNT FOR PUMA1S -- DONT CHANGE JUST LOOK AT your PUMA1  */
  84. proc sql;
  85. select puma1, count(*) as N_Obs
  86. from newunits
  87. group by puma1;
  88. quit;
  89. /* TOTAL FOR 34011: 1693 */
  90.  
  91. /*Get count of low income households based on listed conditions*/
  92. proc sql;
  93. select count(*) as N_Obs
  94. from newunits
  95. where
  96. puma1=34011
  97. and
  98. (hht=1 or hht=2 or hht=3)
  99. and
  100. (persons=4 and hinc<.8*(61000)
  101. or
  102. persons=3 and hinc< .9*(.8*(61000))
  103. or
  104.  persons=2 and hinc< .8*(.8*(61000))
  105. or
  106.  persons=5 and hinc< 1.08*(.8*(61000))
  107. or
  108. persons=6 and hinc< 1.16*(.8*(61000))
  109. )
  110. and
  111. persons <= rooms
  112. and
  113. ((smocapi<= 30 & smocapi>0) or (grapi<=30 & grapi>0));
  114. quit;
  115.  
  116. /* COUNT IS 105 */
  117.  
  118. /*Proportion : 105/1693 = .06202 */
  119.  
  120. /* CALCULATE PROPORTION OF AFFORDABLE AND NOT CROWDED AMONG NEW UNITS OCCUPIED BY LOW INCOME FAMILIES */
  121.  
  122. /* change set */
  123. DATA NULI;
  124. SET project.gnj;
  125. where (yrbuilt=1
  126. or
  127. yrbuilt=2
  128. or
  129. yrbuilt=3)
  130. and
  131. ((hht=1 or hht=2 or hht=3)
  132. and
  133. persons=4 and hinc<.8*(61000)
  134. or
  135. persons=3 and hinc< .9*(.8*(61000))
  136. or
  137.  persons=2 and hinc< .8*(.8*(61000))
  138. or
  139.  persons=5 and hinc< 1.08*(.8*(61000))
  140. or
  141. persons=6 and hinc< 1.16*(.8*(61000))
  142. );
  143. run;
  144.  
  145. /*GIVES TOTAL COUNT FOR PUMA1S -- DONT CHANGE JUST LOOK AT your PUMA1  */
  146. proc sql;
  147. select puma1, count(*) as N_Obs
  148. from NULI
  149. group by puma1;
  150. quit;
  151. /* TOTAL FOR 34011 : 361*/
  152.  
  153.  
  154. /*Get count of low income households based on listed conditions -- change puma1*/
  155. proc sql;
  156. select count(*) as N_Obs
  157. from NULI
  158. where
  159. puma1=34011
  160. and
  161. persons <= rooms
  162. and
  163. ((smocapi<= 30 & smocapi >0) or (grapi<=30 & grapi>0));
  164. quit;
  165. /*N_Obs =111*/
  166.  
  167. /*Proportion : 111/361 = .307479*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement