I have two tables, users table and leave table which stores all the information for the user who have captured leave.
I need help in adding people who did not apply leave in table Leave_new with 0 value under leave_days column
data users;
input users $50.;
datalines;
Andrew Lup
Dan Louis
Mike Mora
Farren Farrao
Joseph Mia
;
run;
data leave;
input calender_month leave_days leave_type_code username $50.;
datalines;
202101 1 2 Andrew Lup
202101 1 2 Andrew Lup
202101 1 2 Sol Sebe
202001 1 2 Ant Joe
202101 1 2 Dan Louis
202101 1 2 Mike Mora
202101 1 2 Mike Mora
202101 1 2 Mike Mora
202101 1 2 Mike Mora
;
proc sql;
create table Leave_new as
select distinct
a.username,
a.calender_month,
sum(a.leave_days) as leave_days
from have as a
where a.username in (select users from users)
group by 1,2
;quit;
Data Want
username
calender_month
leave_days
Andrew Lup
202101
2
Dan Louis
202101
1
Farren Farrao
202101
0
Joseph Mia
202101
0
Mike Mora
202101
4
... View more