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
Lapis Lazuli | Level 10
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
Lapis Lazuli | Level 10
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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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