Advertisement
Guest User

Untitled

a guest
Nov 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 7.52 KB | None | 0 0
  1. /* ALL NEW JERSEY */
  2. /* Get the summary statistics */
  3. PROC MEANS DATA=PROJECT.gnj mean median n stddev min max;
  4. var finc hinc ;
  5. run;
  6.  
  7. /* CALCULATE PROPORTION OF LOW INCOME FAMILIES */
  8.  
  9. /* Get data with households that house a single family */
  10. DATA singlefamilyhht;
  11. SET project.gnj;
  12. IF hht=1 or hht=2 or hht=3;
  13. run;
  14. /*Total Number of Rows = 107529 */
  15.  
  16. /*median of single family household*/
  17. PROC MEANS data=singlefamilyhht(where=(persons=4)) median;
  18. var hinc;
  19. weight hweight;
  20. run;
  21. /*Note median =76000.00*/
  22.  
  23. /*
  24. data step;
  25. set singlefamilyhht;
  26. low_income=0;
  27. if persons=4 and hinc<.8*(76000) then low_income = 1;
  28. if persons=3 and hinc< .9*(.8*(76000)) then low_income = 1;
  29. if persons=2 and hinc< .8*(.8*(76000))then low_income = 1;
  30. if persons=5 and hinc< 1.08*(.8*(76000)) then low_income = 1;
  31. if persons=6 and hinc< 1.16*(.8*(76000)) then low_income = 1;
  32. count = 1;
  33. run;
  34.  
  35. Proc sql;
  36. Create table Step2 as
  37. Select SUM(low_income) AS low_income, sum(count) as total
  38. From step
  39. ;
  40. */
  41.  
  42. /*Get count of low income households based on listed conditions*/
  43. proc sql;
  44. select count(*) as N_Obs
  45. from singlefamilyhht
  46. where persons=4 and hinc<.8*(76000)
  47. or
  48. persons=3 and hinc< .9*(.8*(76000))
  49. or
  50.  persons=2 and hinc< .8*(.8*(76000))
  51. or
  52.  persons=5 and hinc< 1.08*(.8*(76000))
  53. or
  54. persons=6 and hinc< 1.16*(.8*(76000));
  55. quit;
  56. /*N_Obs =41468*/
  57.  
  58. /*Proportion : 41468/107529 = .38564 */
  59.  
  60.  
  61. /* CALCULATE PROPORTION OF LOW INCOME, AFFORDABLE, AND NOT CROWDED AMONG NEW UNITS  */
  62. DATA newunits;
  63. SET project.gnj;
  64. IF yrbuilt=1
  65. or
  66. yrbuilt=2
  67. or
  68. yrbuilt=3;
  69. run;
  70. /*Total Number of Rows = 15275*/
  71.  
  72.  
  73. /*Get count of low income households based on listed conditions*/
  74. proc sql;
  75. select count(*) as N_Obs
  76. from newunits
  77. where
  78. ((hht=1 or hht=2 or hht=3)
  79. and persons=4 and hinc<.8*(76000)
  80. or
  81. persons=3 and hinc< .9*(.8*(76000))
  82. or
  83.  persons=2 and hinc< .8*(.8*(76000))
  84. or
  85.  persons=5 and hinc< 1.08*(.8*(76000))
  86. or
  87. persons=6 and hinc< 1.16*(.8*(76000))
  88. )
  89. and
  90. persons <= rooms
  91. and
  92. (smocapi<= 30 or grapi<=30);
  93. quit;
  94.  
  95. /*N_Obs =3124*/
  96.  
  97. /*Proportion : 3124/15275 = .20452 */
  98.  
  99. /* CALCULATE PROPORTION OF AFFORDABLE AND NOT CROWDED AMONG NEW UNITS OCCUPIED BY LOW INCOME FAMILIES */
  100.  
  101. DATA NULI;
  102. SET project.gnj;
  103. where (yrbuilt=1
  104. or
  105. yrbuilt=2
  106. or
  107. yrbuilt=3)
  108. and
  109. ((hht=1 or hht=2 or hht=3)
  110. and
  111. persons=4 and hinc<.8*(76000)
  112. or
  113. persons=3 and hinc< .9*(.8*(76000))
  114. or
  115.  persons=2 and hinc< .8*(.8*(76000))
  116. or
  117.  persons=5 and hinc< 1.08*(.8*(76000))
  118. or
  119. persons=6 and hinc< 1.16*(.8*(76000))
  120. );
  121. run;
  122. /*Total Number of Rows = 3386*/
  123.  
  124.  
  125. /*Get count of low income households based on listed conditions*/
  126. proc sql;
  127. select count(*) as N_Obs
  128. from NULI
  129. where
  130. persons <= rooms
  131. and
  132. (smocapi<= 30 or grapi<=30);
  133. quit;
  134. /*N_Obs =3124*/
  135.  
  136. /*Proportion : 3124/3386 = .92262*/
  137.  
  138. /* ALL OKLAHOMA */
  139. DATA oklahoma;
  140. SET project.g6oklcol;
  141. IF state=40;
  142. run;
  143. /*Total Number of Rows = 63590 */
  144.  
  145. /* CALCULATE PROPORTION OF LOW INCOME FAMILIES */
  146. /* Get data with households that house a single family */
  147. DATA singlefamilyhht2;
  148. SET oklahoma;
  149. IF hht=1 or hht=2 or hht=3;
  150. run;
  151. /*Total Number of Rows = 45568 */
  152.  
  153. /*median of single family household*/
  154. PROC MEANS data=singlefamilyhht2(where= (persons=4)) median;
  155. var hinc;
  156. weight hweight;
  157. run;
  158. /*Note median =47000*/
  159.  
  160. /*Get count of low income households based on listed conditions*/
  161. proc sql;
  162. select count(*) as N_Obs
  163. from singlefamilyhht2
  164. where persons=4 and hinc<.8*(47000)
  165. or
  166. persons=3 and hinc< .9*(.8*(47000))
  167. or
  168.  persons=2 and hinc< .8*(.8*(47000))
  169. or
  170.  persons=5 and hinc< 1.08*(.8*(47000))
  171. or
  172. persons=6 and hinc< 1.16*(.8*(47000));
  173. quit;
  174. /*N_Obs =13812*/
  175.  
  176. /*Proportion : 18274/45568 = .4010 */
  177.  
  178.  
  179. /* CALCULATE PROPORTION OF LOW INCOME, AFFORDABLE, AND NOT CROWDED AMONG NEW UNITS  */
  180. DATA newunits2;
  181. SET oklahoma;
  182. IF yrbuilt=1
  183. or
  184. yrbuilt=2
  185. or
  186. yrbuilt=3;
  187. run;
  188. /*Total Number of Rows = 8827*/
  189.  
  190.  
  191. /*Get count of low income households based on listed conditions*/
  192. proc sql;
  193. select count(*) as N_Obs
  194. from newunits2
  195. where
  196. ((hht=1 or hht=2 or hht=3)
  197. and
  198. persons=4 and hinc<.8*(47000)
  199. or
  200. persons=3 and hinc< .9*(.8*(47000))
  201. or
  202.  persons=2 and hinc< .8*(.8*(47000))
  203. or
  204.  persons=5 and hinc< 1.08*(.8*(47000))
  205. or
  206. persons=6 and hinc< 1.16*(.8*(47000))
  207. )
  208. and
  209. persons <= rooms
  210. and
  211. (smocapi<= 30 or grapi<=30);
  212. quit;
  213. /*N_Obs =2240*/
  214.  
  215. /*Proportion : 2240/8827 = .25377 */
  216.  
  217. /* CALCULATE PROPORTION OF AFFORDABLE AND NOT CROWDED AMONG NEW UNITS OCCUPIED BY LOW INCOME FAMILIES */
  218.  
  219. DATA NULI2;
  220. SET oklahoma;
  221. where (yrbuilt=1
  222. or
  223. yrbuilt=2
  224. or
  225. yrbuilt=3)
  226. and
  227. ((hht=1 or hht=2 or hht=3)
  228. and persons=4 and hinc<.8*(47000)
  229. or
  230. persons=3 and hinc< .9*(.8*(47000))
  231. or
  232.  persons=2 and hinc< .8*(.8*(47000))
  233. or
  234.  persons=5 and hinc< 1.08*(.8*(47000))
  235. or
  236. persons=6 and hinc< 1.16*(.8*(47000))
  237. );
  238. run;
  239. /*Total Number of Rows = 2386*/
  240.  
  241.  
  242. /*Get count of low income households based on listed conditions*/
  243. proc sql;
  244. select count(*) as N_Obs
  245. from NULI2
  246. where
  247. persons <= rooms
  248. and
  249. (smocapi<= 30 or grapi<=30);
  250. quit;
  251. /*N_Obs =2240*/
  252.  
  253. /*Proportion : 2240/2386 = .9388 */
  254.  
  255. /* ALL COLORADO */
  256. DATA colorado;
  257. SET project.g6oklcol;
  258. IF state=8;
  259. run;
  260. /*Total Number of Rows = 80732 */
  261.  
  262. /* CALCULATE PROPORTION OF LOW INCOME FAMILIES */
  263. /* Get data with households that house a single family */
  264. DATA singlefamilyhht3;
  265. SET colorado;
  266. IF hht=1 or hht=2 or hht=3;
  267. run;
  268. /*Total Number of Rows = 54168 */
  269.  
  270. /*median of single family household*/
  271. PROC MEANS data=singlefamilyhht3(where= (persons=4)) median;
  272. var hinc;
  273. weight hweight;
  274. run;
  275. /*Note median =63500.00*/
  276.  
  277. /*Get count of low income households based on listed conditions*/
  278. proc sql;
  279. select count(*) as N_Obs
  280. from singlefamilyhht3
  281. where
  282. (hht=1 or hht=2 or hht=3)
  283. and
  284. persons=4 and hinc<.8*(63500)
  285. or
  286. persons=3 and hinc< .9*(.8*(63500))
  287. or
  288.  persons=2 and hinc< .8*(.8*(63500))
  289. or
  290.  persons=5 and hinc< 1.08*(.8*(63500))
  291. or
  292. persons=6 and hinc< 1.16*(.8*(63500));
  293. quit;
  294. /*N_Obs =20617*/
  295.  
  296. /*Proportion : 15516/54168 = .28644 */
  297.  
  298.  
  299. /* CALCULATE PROPORTION OF LOW INCOME, AFFORDABLE, AND NOT CROWDED AMONG NEW UNITS  */
  300. DATA newunits3;
  301. SET colorado;
  302. IF yrbuilt=1
  303. or
  304. yrbuilt=2
  305. or
  306. yrbuilt=3;
  307. run;
  308. /*Total Number of Rows = 17020*/
  309.  
  310.  
  311. /*Get count of low income households based on listed conditions*/
  312. proc sql;
  313. select count(*) as N_Obs
  314. from newunits3
  315. where
  316. ((hht=1 or hht=2 or hht=3)
  317. and persons=4 and hinc<.8*(63500)
  318. or
  319. persons=3 and hinc< .9*(.8*(63500))
  320. or
  321.  persons=2 and hinc< .8*(.8*(63500))
  322. or
  323.  persons=5 and hinc< 1.08*(.8*(63500))
  324. or
  325. persons=6 and hinc< 1.16*(.8*(63500))
  326. )
  327. and
  328. persons <= rooms
  329. and
  330. (smocapi<= 30 or grapi<=30);
  331. quit;
  332. /*N_Obs =3515*/
  333.  
  334. /*Proportion : 3515/17020 = .20652 */
  335.  
  336. /* CALCULATE PROPORTION OF AFFORDABLE AND NOT CROWDED AMONG NEW UNITS OCCUPIED BY LOW INCOME FAMILIES */
  337.  
  338. DATA NULI3;
  339. SET colorado;
  340. where (yrbuilt=1
  341. or
  342. yrbuilt=2
  343. or
  344. yrbuilt=3)
  345. and
  346. ((hht=1 or hht=2 or hht=3)
  347. and persons=4 and hinc<.8*(63500)
  348. or
  349. persons=3 and hinc< .9*(.8*(63500))
  350. or
  351.  persons=2 and hinc< .8*(.8*(63500))
  352. or
  353.  persons=5 and hinc< 1.08*(.8*(63500))
  354. or
  355. persons=6 and hinc< 1.16*(.8*(63500))
  356. );
  357. run;
  358. /*Total Number of Rows = 3818*/
  359.  
  360.  
  361. /*Get count of low income households based on listed conditions*/
  362. proc sql;
  363. select count(*) as N_Obs
  364. from NULI3
  365. where
  366. persons <= rooms
  367. and
  368. (smocapi<= 30 or grapi<=30);
  369. quit;
  370. /*N_Obs =3793*/
  371.  
  372. /*Proportion : 3515/3818 = .9206 */
  373.  
  374.  
  375.  
  376.  
  377. proc sql;
  378. select puma1, count(*) as obs
  379. from oklahoma
  380. group by puma1;
  381. quit;
  382.  
  383. proc sql;
  384. select puma1, count(*) as obs
  385. from colorado
  386. group by puma1;
  387. quit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement