Advertisement
Guest User

PropLowProportion

a guest
Nov 24th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 1.17 KB | None | 0 0
  1. data step1;
  2. set Rep2.overall;
  3. where hht = 1 and persons = 4;
  4. keep state lhinc hinc persons;
  5. run;
  6.  
  7. proc sort;
  8. by state;
  9. run;
  10.  
  11. Proc Means Data=step1 chartype Median Mean MAx;
  12. by state;
  13. Var HINC;
  14. output out = c;
  15. Run;
  16.  
  17. data Step2;
  18. input state median;
  19. datalines;
  20. 8 65800.00
  21. 34 82500.00
  22. 40 48405.00
  23. ;
  24.  
  25. data Step3;
  26. set Step2;
  27. fourp = .8*median;
  28. threep = .9*.8*median;
  29. twop = .8*.8*median;
  30. fivep = 1.08*.8*median;
  31. sixp = 1.16*.8*median;
  32. run;
  33.  
  34. data step4;
  35. set rep2.overall;
  36. if hht ne 1 then delete;
  37. keep state persons hinc hht;
  38. run;
  39. proc sort;
  40. by state;
  41. run;
  42. data step4;
  43. merge step3 step4;
  44. by state;
  45. run;
  46.  
  47.  
  48. data step5;
  49. set step4;
  50. low_income = 0;
  51. if persons = 2 and hinc < twop then low_income = 1;
  52. if persons = 3 and hinc < threep then low_income = 1;
  53. if persons = 4 and hinc < fourp then low_income = 1;
  54. if persons = 5 and hinc < fivep then low_income = 1;
  55. if persons = 6 and hinc < sixp then low_income = 1;
  56. count = 1;
  57. run;
  58.  
  59. Proc sql;
  60. Create table Step6 as
  61. Select state, SUM(low_income) AS low_income, sum(count) as total
  62. From Step5
  63. group by state
  64. ;
  65. Proc sql;
  66. Create table Step7 as
  67. Select *, low_income/total as ratio
  68. From Step6
  69. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement