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

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