BookmarkSubscribeRSS Feed
augustcrez
Calcite | Level 5

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! 

 

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20
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;
Astounding
PROC Star

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?

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
  • 2 replies
  • 829 views
  • 0 likes
  • 3 in conversation