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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 579 views
  • 0 likes
  • 2 in conversation