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?

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 905 views
  • 0 likes
  • 3 in conversation