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,

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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