Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- accrual_date absence_type duration_days employee_id
- 01JAN2001:00:00:00 010 10.20 1
- 01JAN2001:00:00:00 014 11 1
- 01JAN2003:00:00:00 001 12 1
- 01JAN2002:00:00:00 015 30 2
- 01JAN2001:00:00:00 015 20 2
- employee_id duration_days_010 duration_days_014 duration_days_015
- 1 10.20 11 .
- 2 . . 50
- proc sql;
- create table sort_first as
- select *
- from REQUEST
- where absence_type='014' or absence_type='015' or absence_type='010'
- ;
- quit;
- proc sql;
- create table sort_second as
- select
- case when absence_type='014' then sum(duration_days) else . end as duration_days_014,
- case when absence_type='015' then sum(duration_days) else . end as duration_days_015,
- case when absence_type='010' then sum(duration_days) else . end as duration_days_010,
- employee_id, absence_type
- from sort_first
- group by emplid;
- quit;
- proc sort data=sort_second out=test1 nodupkey;
- by emplid;
- quit;
- employee_id duration_days_010 duration_days_014 duration_days_015
- 1 21.20 21.20 .
- 2 . . 50
- ods output table=want;
- proc tabulate data=have;
- where absence_type in (10,14,15);
- class absence_type employee_id;
- var duration_days;
- tables employee_id,absence_type*duration_days*sum;
- run;
- proc transpose data=want out=final prefix=duration_days_;
- by employee_id;
- id absence_type;
- var duration_days_sum;
- run;
- case when absence_type='014' then sum(duration_days) else . end as duration_days_014,
- sum(case when absence_type='014' then duration_days else . end) as duration_days_014,
- proc sql;
- create table final as
- select
- sum (case when absence_type=014 then duration_days else . end) as duration_days_014,
- sum (case when absence_type=015 then duration_days else . end) as duration_days_015,
- sum (case when absence_type=010 then duration_days else . end) as duration_days_010,
- employee_id
- from have
- group by employee_id;
- quit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement