BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
misaochan
Calcite | Level 5

I have three datasets, each containing the values of a variable for a different 6-month period, and I'm trying to use their values as the time-dependent explanatory variable, in a proportional hazards model (PROC PHREG). Basically, from time 1 to time 6, I want the value of the explanatory variable to be the value from table 1; from time 7 to 12 I want the value of the same explanatory variable to be the value from table 2, etc.


I know I will have to join all the datasets before I run PHREG, but my question is how do I flag them prior to that, to allow me to differentiate the values coming from each dataset?


(EDIT) To clarify what I mean:


Dataset 1 contains the values of variable "Measurement" for the period Jan 2010 - Jun 2010

Dataset 2 contains the values of variable "Measurement" for the period Jul 2011 - Dec 2011

Dataset 3 contains the values of variable "Measurement" for the period Jan 2011 - Jun 2011


I want to combine the values of "Measurement" from all 3 datasets into one single model for PHREG, that selects the value from Dataset 1 during time 1 to time 6, the value from Dataset 2 from time 7 to time 12, and the value from Dataset 3 from time 13 to time 18. What would be a good and clean way to do this?


Greatly appreciate any help.

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

Yes, if interested in 0<time<6 then flag=1 will be used in PROC PHREG.

Thanks,

View solution in original post

4 REPLIES 4
misaochan
Calcite | Level 5

Anyone? Is there any additional information I could provide that would be helpful? I don't need help with the specifics of PHREG per se, just how to copy over same-variable values from other datasets and handle the differentiation in the code.

stat_sas
Ammonite | Level 13

If I understood your questions correctly. You are looking for combining 3 datasets and want to flag them. Please see the below

data overall;

set dataset1(in=a) dataset2(in=b) dataset3(in=c);

if a then flag=1;

if b then flag=2;

if c then flag=3;

run;

Make sure common variables must have the same attributes.

misaochan
Calcite | Level 5

Thank you, yes, that is the gist of it. But in the PROC PHREG code I will need to specify that I want to choose the values with flag=1 if 0<time<6. I think I will not be able to incorporate the flags into the model, as they will be a separate variable from the value itself?

stat_sas
Ammonite | Level 13

Yes, if interested in 0<time<6 then flag=1 will be used in PROC PHREG.

Thanks,

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1630 views
  • 3 likes
  • 2 in conversation