Hi all,
I have a data as following
Subj tpt grpid
1 24 bd
1 36 bid
1 72
And many more. I want when my tpt is 72 and irrespective of grpid missing or non missing should take grpid of tpt=24
So my data should look
Subj tpt grpid
1 24 qd
1 36 bid
1 72 qd
Please help!
data have;
input Subj tpt grpid $;
infile datalines missover;
datalines;
1 24 bd
1 36 bid
1 72
;
data want(drop=temp);
set have;
if tpt=24 then temp=grpid;
if tpt=72 then grpid=temp;
retain temp;
run;
Some questions that might determine whether a solution works or not:
Will each SUBJ always have a TPT=24 record?
If so, will the TPT=24 record always come before the TPT=72 record?
If not, what should happen on the TPT=72 record?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.