I have a matched population (1:2) as reported below.
I want that the two controls to get the same "rhythm" variable as the matched case instead of missing. Any suggestion to how to program it?
caseid event rhythm
1 0 .
1 0 .
1 1 1
2 0 .
2 0 .
2 1 2
3 0 .
3 0 .
3 1 1
Lke this?
data have;
input caseid event rhythm;
datalines;
1 0 .
1 0 .
1 1 1
2 0 .
2 0 .
2 1 2
3 0 .
3 0 .
3 1 1
;
proc sql;
create table want as
select caseId, event, max(rhythm) as rhythm
from have
group by caseId
order by caseId, event;
quit;
Lke this?
data have;
input caseid event rhythm;
datalines;
1 0 .
1 0 .
1 1 1
2 0 .
2 0 .
2 1 2
3 0 .
3 0 .
3 1 1
;
proc sql;
create table want as
select caseId, event, max(rhythm) as rhythm
from have
group by caseId
order by caseId, event;
quit;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.