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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 311 views
  • 1 like
  • 2 in conversation