I have created to tables using code below. How to have in one table the variables total_kids and tot_0_5 using sql?
x
proc sql;
create table total as select *,
count (distinct var_name1) as total_name
from data
group by var_name2
order by total_name;
proc sql;
create table total as select (*),
count (distinct id) as var_name
from data where age='age_category'
group by var_name
order var_name;
Advertisement
Answer
You can use conditional aggregation:
select drug,
count(distinct mbr_id) as total_kids,
count(distinct case when agecat = '0-5' then mbr_id end) as tot_0_5
from dt
group by drug
order by total_kids;