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?