Advertisement
Guest User

Untitled

a guest
Nov 27th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 9.35 KB | None | 0 0
  1. /* ALL OKLAHOMA */
  2.  
  3. /* CALCULATE PROPORTION OF LOW INCOME FAMILIES */
  4.  
  5. /* Get data with households that house a single family */
  6. DATA singlefamilyhhtokl;
  7. SET project.g6oklcol;
  8. IF state=40;
  9. IF hht=1 or hht=2 or hht=3;
  10. run;
  11. /*Total Number of Rows = 45568 */
  12.  
  13. proc sql;
  14. select puma1, count(*) as N_Obs
  15. from singlefamilyhhtokl
  16. group by puma1;
  17. quit;
  18.  
  19. /*median of single family household*/
  20. PROC MEANS data=singlefamilyhhtokl(where=(persons=4)) median noprint;
  21. class puma1;
  22. var hinc;
  23. weight hweight;
  24. output out = test median= med;
  25. run;
  26. proc print data=test;
  27. run;
  28.  
  29.  
  30. /*Get count of low income households based on listed conditions*/
  31. proc sql;
  32. select count(*) as N_Obs
  33. from singlefamilyhhtokl
  34. where puma1=40100
  35. and
  36. (persons=4 and hinc<.8*(42900)
  37. or
  38. persons=3 and hinc< .9*(.8*(42900))
  39. or
  40. persons=2 and hinc< .8*(.8*(42900))
  41. or
  42. persons=5 and hinc< 1.08*(.8*(42900))
  43. or
  44. persons=6 and hinc< 1.16*(.8*(42900))
  45. );
  46. quit;
  47.  
  48. /*N_Obs=3398*/
  49.  
  50. /*Proportion : 3398/9228=0.36822*/
  51.  
  52. proc sql;
  53. select count(*) as N_Obs
  54. from singlefamilyhhtokl
  55. where puma1=40201
  56. and
  57. (persons=4 and hinc<.8*(49000)
  58. or
  59. persons=3 and hinc< .9*(.8*(49000))
  60. or
  61. persons=2 and hinc< .8*(.8*(49000))
  62. or
  63. persons=5 and hinc< 1.08*(.8*(49000))
  64. or
  65. persons=6 and hinc< 1.16*(.8*(49000))
  66. );
  67. quit;
  68.  
  69. /*N_Obs = 1655*/
  70.  
  71. /*Proportion :  = 1655/4451=0.371826*/
  72.  
  73. proc sql;
  74. select count(*) as N_Obs
  75. from singlefamilyhhtokl
  76. where puma1=40202
  77. and
  78. (persons=4 and hinc<.8*(51000)
  79. or
  80. persons=3 and hinc< .9*(.8*(51000))
  81. or
  82. persons=2 and hinc< .8*(.8*(51000))
  83. or
  84. persons=5 and hinc< 1.08*(.8*(51000))
  85. or
  86. persons=6 and hinc< 1.16*(.8*(51000))
  87. );
  88. quit;
  89.  
  90. /*N_Obs=3135*/
  91.  
  92. /*Proportion :  = 3135/8127=0.3857512*/
  93.  
  94. proc sql;
  95. select count(*) as N_Obs
  96. from singlefamilyhhtokl
  97. where
  98. puma1=40300
  99. and
  100. (persons=4 and hinc<.8*(41000)
  101. or
  102. persons=3 and hinc< .9*(.8*(41000))
  103. or
  104. persons=2 and hinc< .8*(.8*(41000))
  105. or
  106. persons=5 and hinc< 1.08*(.8*(41000))
  107. or
  108. persons=6 and hinc< 1.16*(.8*(41000))
  109. );
  110. quit;
  111.  
  112. /*N_Obs=2819*/
  113.  
  114. /*Proportion :  = 2819/7405=0.380688*/
  115.  
  116. proc sql;
  117. select count(*) as N_Obs
  118. from singlefamilyhhtokl
  119. where puma1=40400
  120. and
  121. (persons=4 and hinc<.8*(56420)
  122. or
  123. persons=3 and hinc< .9*(.8*(56420))
  124. or
  125. persons=2 and hinc< .8*(.8*(56420))
  126. or
  127. persons=5 and hinc< 1.08*(.8*(56420))
  128. or
  129. persons=6 and hinc< 1.16*(.8*(56420))
  130. );
  131. quit;
  132.  
  133. /*N_Obs=2529*/
  134.  
  135. /*Proportion :  = 2529/6566=0.385166*/
  136.  
  137. proc sql;
  138. select count(*) as N_Obs
  139. from singlefamilyhhtokl
  140. where puma1=40500
  141. and
  142. (persons=4 and hinc<.8*(37000)
  143. or
  144. persons=3 and hinc< .9*(.8*(37000))
  145. or
  146. persons=2 and hinc< .8*(.8*(37000))
  147. or
  148. persons=5 and hinc< 1.08*(.8*(37000))
  149. or
  150. persons=6 and hinc< 1.16*(.8*(37000))
  151. );
  152. quit;
  153.  
  154. /*N_Obs=3573*/
  155.  
  156. /*Proportion :  = 3573/9791=0.364926*/
  157.  
  158.  
  159.  
  160.  
  161.  
  162. /* gives data for new units --  change set */
  163. DATA newunits;
  164. SET project.g6oklcol;
  165. IF yrbuilt=1
  166. or
  167. yrbuilt=2
  168. or
  169. yrbuilt=3;
  170. WHERE state=40;
  171. run;
  172.  
  173. proc sql;
  174. select puma1, count(*) as N_Obs
  175. from newunits
  176. group by puma1;
  177. quit;
  178.  
  179. /* LOW INCOME HOUSEHOLDS BASED ON CONDITIONS*/
  180. proc sql;
  181. select count(*) as N_Obs
  182. from newunits
  183. where
  184. puma1=40100
  185. and
  186. (hht=1 or hht=2 or hht=3)
  187. and
  188. (persons=4 and hinc<.8*(42900)
  189. or
  190. persons=3 and hinc< .9*(.8*(42900))
  191. or
  192.  persons=2 and hinc< .8*(.8*(42900))
  193. or
  194.  persons=5 and hinc< 1.08*(.8*(42900))
  195. or
  196. persons=6 and hinc< 1.16*(.8*(42900))
  197. )
  198. and
  199. persons <= rooms
  200. and
  201. ((smocapi<= 30 & smocapi>0) or (grapi<=30 & grapi>0));
  202. quit;
  203.  
  204. proc sql;
  205. select count(*) as N_Obs
  206. from newunits
  207. where
  208. puma1=40201
  209. and
  210. (hht=1 or hht=2 or hht=3)
  211. and
  212. (persons=4 and hinc<.8*(49000)
  213. or
  214. persons=3 and hinc< .9*(.8*(49000))
  215. or
  216.  persons=2 and hinc< .8*(.8*(49000))
  217. or
  218.  persons=5 and hinc< 1.08*(.8*(49000))
  219. or
  220. persons=6 and hinc< 1.16*(.8*(49000))
  221. )
  222. and
  223. persons <= rooms
  224. and
  225. ((smocapi<= 30 & smocapi>0) or (grapi<=30 & grapi>0));
  226. quit;
  227.  
  228. proc sql;
  229. select count(*) as N_Obs
  230. from newunits
  231. where
  232. puma1=40202
  233. and
  234. (hht=1 or hht=2 or hht=3)
  235. and
  236. (persons=4 and hinc<.8*(51000)
  237. or
  238. persons=3 and hinc< .9*(.8*(51000))
  239. or
  240.  persons=2 and hinc< .8*(.8*(51000))
  241. or
  242.  persons=5 and hinc< 1.08*(.8*(51000))
  243. or
  244. persons=6 and hinc< 1.16*(.8*(51000))
  245. )
  246. and
  247. persons <= rooms
  248. and
  249. ((smocapi<= 30 & smocapi>0) or (grapi<=30 & grapi>0));
  250. quit;
  251.  
  252. proc sql;
  253. select count(*) as N_Obs
  254. from newunits
  255. where
  256. puma1=40300
  257. and
  258. (hht=1 or hht=2 or hht=3)
  259. and
  260. (persons=4 and hinc<.8*(41000)
  261. or
  262. persons=3 and hinc< .9*(.8*(41000))
  263. or
  264.  persons=2 and hinc< .8*(.8*(41000))
  265. or
  266.  persons=5 and hinc< 1.08*(.8*(41000))
  267. or
  268. persons=6 and hinc< 1.16*(.8*(41000))
  269. )
  270. and
  271. persons <= rooms
  272. and
  273. ((smocapi<= 30 & smocapi>0) or (grapi<=30 & grapi>0));
  274. quit;
  275.  
  276. proc sql;
  277. select count(*) as N_Obs
  278. from newunits
  279. where
  280. puma1=40400
  281. and
  282. (hht=1 or hht=2 or hht=3)
  283. and
  284. (persons=4 and hinc<.8*(56420)
  285. or
  286. persons=3 and hinc< .9*(.8*(56420))
  287. or
  288.  persons=2 and hinc< .8*(.8*(56420))
  289. or
  290.  persons=5 and hinc< 1.08*(.8*(56420))
  291. or
  292. persons=6 and hinc< 1.16*(.8*(56420))
  293. )
  294. and
  295. persons <= rooms
  296. and
  297. ((smocapi<= 30 & smocapi>0) or (grapi<=30 & grapi>0));
  298. quit;
  299.  
  300. proc sql;
  301. select count(*) as N_Obs
  302. from newunits
  303. where
  304. puma1=40500
  305. and
  306. (hht=1 or hht=2 or hht=3)
  307. and
  308. (persons=4 and hinc<.8*(37000)
  309. or
  310. persons=3 and hinc< .9*(.8*(37000))
  311. or
  312.  persons=2 and hinc< .8*(.8*(37000))
  313. or
  314.  persons=5 and hinc< 1.08*(.8*(37000))
  315. or
  316. persons=6 and hinc< 1.16*(.8*(37000))
  317. )
  318. and
  319. persons <= rooms
  320. and
  321. ((smocapi<= 30 & smocapi>0) or (grapi<=30 & grapi>0));
  322. quit;
  323.  
  324.  
  325.  
  326. DATA NULI;
  327. SET project.g6oklcol;
  328. where state=40
  329. and
  330. ((yrbuilt=1
  331. or
  332. yrbuilt=2
  333. or
  334. yrbuilt=3))
  335. and
  336. ((hht=1 or hht=2 or hht=3)
  337. and
  338. persons=4 and hinc<.8*(42900)
  339. or
  340. persons=3 and hinc< .9*(.8*(42900))
  341. or
  342.  persons=2 and hinc< .8*(.8*(42900))
  343. or
  344.  persons=5 and hinc< 1.08*(.8*(42900))
  345. or
  346. persons=6 and hinc< 1.16*(.8*(42900))
  347. );
  348. run;
  349.  
  350. proc sql;
  351. select puma1, count(*) as N_Obs
  352. from NULI
  353. group by puma1;
  354. quit;
  355.  
  356.  
  357. /*Get count of low income households based on listed conditions*/
  358. proc sql;
  359. select count(*) as N_Obs
  360. from NULI
  361. where
  362. puma1=40100
  363. and
  364. persons <= rooms
  365. and
  366. ((smocapi<= 30 & smocapi >0) or (grapi<=30 & grapi>0));
  367. quit;
  368.  
  369.  
  370. DATA NULI1;
  371. SET project.g6oklcol;
  372. where state=40
  373. and
  374. ((yrbuilt=1
  375. or
  376. yrbuilt=2
  377. or
  378. yrbuilt=3))
  379. and
  380. ((hht=1 or hht=2 or hht=3)
  381. and
  382. persons=4 and hinc<.8*(49000)
  383. or
  384. persons=3 and hinc< .9*(.8*(49000))
  385. or
  386.  persons=2 and hinc< .8*(.8*(49000))
  387. or
  388.  persons=5 and hinc< 1.08*(.8*(49000))
  389. or
  390. persons=6 and hinc< 1.16*(.8*(49000))
  391. );
  392. run;
  393.  
  394. proc sql;
  395. select puma1, count(*) as N_Obs
  396. from NULI1
  397. group by puma1;
  398. quit;
  399.  
  400.  
  401. /*Get count of low income households based on listed conditions*/
  402. proc sql;
  403. select count(*) as N_Obs
  404. from NULI1
  405. where
  406. puma1=40201
  407. and
  408. persons <= rooms
  409. and
  410. ((smocapi<= 30 & smocapi >0) or (grapi<=30 & grapi>0));
  411. quit;
  412.  
  413. DATA NULI2;
  414. SET project.g6oklcol;
  415. where state=40
  416. and
  417. ((yrbuilt=1
  418. or
  419. yrbuilt=2
  420. or
  421. yrbuilt=3))
  422. and
  423. ((hht=1 or hht=2 or hht=3)
  424. and
  425. persons=4 and hinc<.8*(51000)
  426. or
  427. persons=3 and hinc< .9*(.8*(51000))
  428. or
  429.  persons=2 and hinc< .8*(.8*(51000))
  430. or
  431.  persons=5 and hinc< 1.08*(.8*(51000))
  432. or
  433. persons=6 and hinc< 1.16*(.8*(51000))
  434. );
  435. run;
  436.  
  437. proc sql;
  438. select puma1, count(*) as N_Obs
  439. from NULI2
  440. group by puma1;
  441. quit;
  442.  
  443.  
  444. /*Get count of low income households based on listed conditions*/
  445. proc sql;
  446. select count(*) as N_Obs
  447. from NULI2
  448. where
  449. puma1=40202
  450. and
  451. persons <= rooms
  452. and
  453. ((smocapi<= 30 & smocapi >0) or (grapi<=30 & grapi>0));
  454. quit;
  455.  
  456.  
  457. DATA NULI4;
  458. SET project.g6oklcol;
  459. where state=40
  460. and
  461. ((yrbuilt=1
  462. or
  463. yrbuilt=2
  464. or
  465. yrbuilt=3))
  466. and
  467. ((hht=1 or hht=2 or hht=3)
  468. and
  469. persons=4 and hinc<.8*(56420)
  470. or
  471. persons=3 and hinc< .9*(.8*(56420))
  472. or
  473.  persons=2 and hinc< .8*(.8*(56420))
  474. or
  475.  persons=5 and hinc< 1.08*(.8*(56420))
  476. or
  477. persons=6 and hinc< 1.16*(.8*(56420))
  478. );
  479. run;
  480.  
  481. proc sql;
  482. select puma1, count(*) as N_Obs
  483. from NULI4
  484. group by puma1;
  485. quit;
  486.  
  487.  
  488. /*Get count of low income households based on listed conditions*/
  489. proc sql;
  490. select count(*) as N_Obs
  491. from NULI4
  492. where
  493. puma1=40400
  494. and
  495. persons <= rooms
  496. and
  497. ((smocapi<= 30 & smocapi >0) or (grapi<=30 & grapi>0));
  498. quit;
  499.  
  500. DATA NULI3;
  501. SET project.g6oklcol;
  502. where state=40
  503. and
  504. ((yrbuilt=1
  505. or
  506. yrbuilt=2
  507. or
  508. yrbuilt=3))
  509. and
  510. ((hht=1 or hht=2 or hht=3)
  511. and
  512. persons=4 and hinc<.8*(41000)
  513. or
  514. persons=3 and hinc< .9*(.8*(41000))
  515. or
  516.  persons=2 and hinc< .8*(.8*(41000))
  517. or
  518.  persons=5 and hinc< 1.08*(.8*(41000))
  519. or
  520. persons=6 and hinc< 1.16*(.8*(41000))
  521. );
  522. run;
  523.  
  524. proc sql;
  525. select puma1, count(*) as N_Obs
  526. from NULI3
  527. group by puma1;
  528. quit;
  529.  
  530.  
  531. /*Get count of low income households based on listed conditions*/
  532. proc sql;
  533. select count(*) as N_Obs
  534. from NULI3
  535. where
  536. puma1=40300
  537. and
  538. persons <= rooms
  539. and
  540. ((smocapi<= 30 & smocapi >0) or (grapi<=30 & grapi>0));
  541. quit;
  542.  
  543. DATA NULI5;
  544. SET project.g6oklcol;
  545. where state=40
  546. and
  547. ((yrbuilt=1
  548. or
  549. yrbuilt=2
  550. or
  551. yrbuilt=3))
  552. and
  553. ((hht=1 or hht=2 or hht=3)
  554. and
  555. persons=4 and hinc<.8*(37000)
  556. or
  557. persons=3 and hinc< .9*(.8*(37000))
  558. or
  559.  persons=2 and hinc< .8*(.8*(37000))
  560. or
  561.  persons=5 and hinc< 1.08*(.8*(37000))
  562. or
  563. persons=6 and hinc< 1.16*(.8*(37000))
  564. );
  565. run;
  566.  
  567. proc sql;
  568. select puma1, count(*) as N_Obs
  569. from NULI5
  570. group by puma1;
  571. quit;
  572.  
  573.  
  574. /*Get count of low income households based on listed conditions*/
  575. proc sql;
  576. select count(*) as N_Obs
  577. from NULI5
  578. where
  579. puma1=40500
  580. and
  581. persons <= rooms
  582. and
  583. ((smocapi<= 30 & smocapi >0) or (grapi<=30 & grapi>0));
  584. quit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement