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 ID | Timepoint | Cohort # |
1 | scr | 1 |
1 | bl | . |
1 | w8 | . |
1 | m6 | . |
1 | m12 | . |
2 | scr | 1 |
2 | bl | . |
2 | w8 | . |
3 | scr | 2 |
3 | bl | . |
3 | w8 | . |
What I want:
Record ID | Timepoint | Cohort # |
1 | scr | 1 |
1 | bl | 1 |
1 | w8 | 1 |
1 | m6 | 1 |
1 | m12 | 1 |
2 | scr | 1 |
2 | bl | 1 |
2 | w8 | 1 |
3 | scr | 2 |
3 | bl | 2 |
3 | w8 | 2 |
Thank you!
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;
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: