HI All,
I think this is q simple question, but uncertain how to work it out.
So far as I recall, maybe use RETAIN, but have no clue on. Hope someone can favor me.
Thank you.
Jack
/*-------------------------------------------------------*/
Below picture is the dummy data, I would like to record the same dose lifecycle trajactory.
what I want to have is:
exdose subjid dose_st_dt dose_en_dt
110mg 615010 2021-12-10 2022-01-19
0mg 615010 2022-01-20 2022-01-23
110mg 615010 2022-01-24 2022-02-15
0mg 615010 2022-02-16 2022-02-22
55mg 615010 2022-02-23 2022-03-29
From now on, please do not provide data as screen captures, we can't write programs to use screen capture data. Instead, we need data provided as SAS data step code which you can type in yourself, or via these instructions.
Also, it would help if you provided a clear description of how the final table is calculated from the input data. Don't make us guess, sometimes we get it wrong.
So, without actual data, my code is UNTESTED. It is also based on my guesses as to what the method is, and maybe I guessed wrong.
data intermediate;
set have;
prev_exdose=lag(exdose);
prev_subj=lag(subjid);
if (exdose^=prev_exdose and subjid=prev_subj) or subjid^=prev_subj then group+1;
run;
proc summary data=intermediate nway;
class group;
id exdose subjid;
var dose_st_dt dose_en_dt;
output out=want min(dose_st_date)= max(dose_en_dt)=;
run;
From now on, please do not provide data as screen captures, we can't write programs to use screen capture data. Instead, we need data provided as SAS data step code which you can type in yourself, or via these instructions.
Also, it would help if you provided a clear description of how the final table is calculated from the input data. Don't make us guess, sometimes we get it wrong.
So, without actual data, my code is UNTESTED. It is also based on my guesses as to what the method is, and maybe I guessed wrong.
data intermediate;
set have;
prev_exdose=lag(exdose);
prev_subj=lag(subjid);
if (exdose^=prev_exdose and subjid=prev_subj) or subjid^=prev_subj then group+1;
run;
proc summary data=intermediate nway;
class group;
id exdose subjid;
var dose_st_dt dose_en_dt;
output out=want min(dose_st_date)= max(dose_en_dt)=;
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.