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

Hello,

 

I am looking to perform case-control matched analysis.  Currently, I have my data in one dataset with 1 case PtID to 4 control PtIDs and am looking for help to create the ID/ Strata variable for use with analysis.

 

How my data is:

case_PtID 	control_PtID	
97654		23345
97654		34967
97654		54244
97654		87442
11111		84354
11111		39760
11111		13012
11111		93423

How I want my data:

case_PtID 	control_PtID	id
97654		23345		    1
97654		34967		    1
97654		54244		    1
97654		87442		    1
11111		84354		    2
11111		39760		    2
11111		13012		    2
11111		93423		    2
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data have;
input case_PtID control_PtID;
datalines;
97654 23345
97654 34967
97654 54244
97654 87442
11111 84354
11111 39760
11111 13012
11111 93423
;

data want;
   set have;
   by case_PtID notsorted;
   if first.case_PtID then id = sum (id, 1);
   retain id;
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20
data have;
input case_PtID control_PtID;
datalines;
97654 23345
97654 34967
97654 54244
97654 87442
11111 84354
11111 39760
11111 13012
11111 93423
;

data want;
   set have;
   by case_PtID notsorted;
   if first.case_PtID then id = sum (id, 1);
   retain id;
run;
bel2806
Fluorite | Level 6

@PeterClemmensen this worked well, thank you!  Do you know how to use this strata variable in PROC MIXED? 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 548 views
  • 0 likes
  • 2 in conversation