Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. accrual_date absence_type duration_days employee_id
  2. 01JAN2001:00:00:00 010 10.20 1
  3. 01JAN2001:00:00:00 014 11 1
  4. 01JAN2003:00:00:00 001 12 1
  5. 01JAN2002:00:00:00 015 30 2
  6. 01JAN2001:00:00:00 015 20 2
  7.  
  8. employee_id duration_days_010 duration_days_014 duration_days_015
  9. 1 10.20 11 .
  10. 2 . . 50
  11.  
  12. proc sql;
  13. create table sort_first as
  14. select *
  15. from REQUEST
  16. where absence_type='014' or absence_type='015' or absence_type='010'
  17. ;
  18. quit;
  19.  
  20. proc sql;
  21. create table sort_second as
  22. select
  23. case when absence_type='014' then sum(duration_days) else . end as duration_days_014,
  24. case when absence_type='015' then sum(duration_days) else . end as duration_days_015,
  25. case when absence_type='010' then sum(duration_days) else . end as duration_days_010,
  26. employee_id, absence_type
  27. from sort_first
  28. group by emplid;
  29.  
  30. quit;
  31.  
  32. proc sort data=sort_second out=test1 nodupkey;
  33. by emplid;
  34. quit;
  35.  
  36. employee_id duration_days_010 duration_days_014 duration_days_015
  37. 1 21.20 21.20 .
  38. 2 . . 50
  39.  
  40. ods output table=want;
  41. proc tabulate data=have;
  42. where absence_type in (10,14,15);
  43. class absence_type employee_id;
  44. var duration_days;
  45. tables employee_id,absence_type*duration_days*sum;
  46. run;
  47.  
  48. proc transpose data=want out=final prefix=duration_days_;
  49. by employee_id;
  50. id absence_type;
  51. var duration_days_sum;
  52. run;
  53.  
  54. case when absence_type='014' then sum(duration_days) else . end as duration_days_014,
  55.  
  56. sum(case when absence_type='014' then duration_days else . end) as duration_days_014,
  57.  
  58. proc sql;
  59. create table final as
  60. select
  61. sum (case when absence_type=014 then duration_days else . end) as duration_days_014,
  62. sum (case when absence_type=015 then duration_days else . end) as duration_days_015,
  63. sum (case when absence_type=010 then duration_days else . end) as duration_days_010,
  64. employee_id
  65. from have
  66. group by employee_id;
  67.  
  68. quit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement