Time-dependent variables in PHREG

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

Time-dependent variables in PHREG

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.


Accepted Solutions
Solution
‎05-18-2014 10:44 AM
Trusted Advisor
Posts: 1,228

Re: Time-dependent variables in PHREG

Posted in reply to misaochan

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

Thanks,

View solution in original post


All Replies
Occasional Contributor
Posts: 18

Re: Time-dependent variables in PHREG

Posted in reply to misaochan

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.

Trusted Advisor
Posts: 1,228

Re: Time-dependent variables in PHREG

Posted in reply to misaochan

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.

Occasional Contributor
Posts: 18

Re: Time-dependent variables in PHREG

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?

Solution
‎05-18-2014 10:44 AM
Trusted Advisor
Posts: 1,228

Re: Time-dependent variables in PHREG

Posted in reply to misaochan

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

Thanks,

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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