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 */
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.