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 */
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!
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.