See Attached. Essentially, I want to have the BMI and treatment group repeated for the given ID. Then I want to assess whether the time frame was during or after by comparing DATE_1 to DATE_2. If DATE_2 occurred before the last DATE_1 for "during", then I want the time period for the X measurements to be labeled "during". If DATE_2 occurred after the first DATE_1 for "after", then I want the time period for X measurements to be labeled "after". I have attempted using the retain statement, but it doesn't seem to do what I expected it to. It seemed to have no effect on the data.
proc sort data = working nodupkey;
by ID PERIOD DATE_1;
run;
data working;
set working;
by ID;
retain TRT BMI DATE_1;
run;
I'm not sure why, but I didn't have the text tools to make the post easy to follow initially. Here's the code attempt rewritten:
proc sort data = working nodupkey;
by ID PERIOD DATE_1;
run;
data working;
set working;
by ID;
retain TRT BMI DATE_1;
run;
/* also tried to retain X1, X2, X3 instead */
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.