BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
carloalberto87
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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;
PG

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21

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;
PG

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 563 views
  • 0 likes
  • 2 in conversation