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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.