BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
tranguyen0205
Calcite | Level 5

Hi, 

 

How can I fill in the cohort number for the same record ID but at different time points?  Please see 

 

What the dataset looks like:

Record IDTimepointCohort #
1scr1
1bl.
1w8.
1m6.
1m12.
2scr 1
2bl .
2w8.
3scr2
3bl.
3w8.

 

 

What I want:

 

Record IDTimepointCohort #
1scr1
1bl1
1w81
1m61
1m121
2scr 1
2bl 1
2w81
3scr2
3bl2
3w82

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
A_Kh
Barite | Level 11
data want;
	set have;
	by recordid;
	retain temp;
	if first.recordid then temp=cohort;
	if cohort eq . then cohort=temp;
	drop temp;
proc print;run; 

View solution in original post

2 REPLIES 2
A_Kh
Barite | Level 11
data want;
	set have;
	by recordid;
	retain temp;
	if first.recordid then temp=cohort;
	if cohort eq . then cohort=temp;
	drop temp;
proc print;run; 
tranguyen0205
Calcite | Level 5
Thanks a lot! It works.

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
  • 917 views
  • 1 like
  • 2 in conversation