Hi, I am working out of SAS Studio and have two different excel datasets I created two KM Survival curves for. For presentation purposes, I wanted to know whether there was a way to have both curves show up in one image so it's easier to compare the two.
Here is the code I have been using so far:
PROC IMPORT DATAFILE="/folders/myshortcuts/SAS_filesUSB/ConcordantKRAS.xlsx"
OUT=ConKRAS
DBMS=XLSX
REPLACE;
Data Survival;
Set ConKRAS (Keep= status SurvivalTime);
run;
Proc Freq;
Tables SurvivalTime STATUS ;
run;
Proc Lifetest Data=Survival Method=KM Plots=(s) Censoredsymbol= '|';
Time SurvivalTime*STATUS (1);
run;
PROC IMPORT DATAFILE="/folders/myshortcuts/SAS_filesUSB/DiscordantKRAS.xlsx"
OUT=DisKRAS
DBMS=XLSX
REPLACE;
Data Survival1;
Set DisKRAS (Keep= status SurvivalTime);
run;
Proc Freq;
Tables SurvivalTime STATUS ;
run;
Proc Lifetest Data=Survival Method=KM Plots=(s) Censoredsymbol= '|';
Time SurvivalTime*STATUS (1);
run;
Any help is much appreciated!
Read in both data sets - with different names.
Append them using a data step and add a variable that indicates the source data set.
Use that as the STRATA variable - AND CHECK THAT THEY'RE the same. I think the calculations are independent with strata's but I can't recall so you should definitely verify that. Untested/unverified.
PROC IMPORT DATAFILE="/folders/myshortcuts/SAS_filesUSB/ConcordantKRAS.xlsx"
OUT=ConKRAS
DBMS=XLSX
REPLACE;
PROC IMPORT DATAFILE="/folders/myshortcuts/SAS_filesUSB/DiscordantKRAS.xlsx"
OUT=DisKRAS
DBMS=XLSX
REPLACE;
run;
Data Survival;
Set ConKRAS (Keep= status SurvivalTime) diskRAS(keep=status survivalTIme) indsname=source;
dsn_name = source;
run;
Proc Lifetest Data=Survival Method=KM Plots=(s) Censoredsymbol= '|';
Time SurvivalTime*STATUS (1);
strata dsn_name;
run;
Read in both data sets - with different names.
Append them using a data step and add a variable that indicates the source data set.
Use that as the STRATA variable - AND CHECK THAT THEY'RE the same. I think the calculations are independent with strata's but I can't recall so you should definitely verify that. Untested/unverified.
PROC IMPORT DATAFILE="/folders/myshortcuts/SAS_filesUSB/ConcordantKRAS.xlsx"
OUT=ConKRAS
DBMS=XLSX
REPLACE;
PROC IMPORT DATAFILE="/folders/myshortcuts/SAS_filesUSB/DiscordantKRAS.xlsx"
OUT=DisKRAS
DBMS=XLSX
REPLACE;
run;
Data Survival;
Set ConKRAS (Keep= status SurvivalTime) diskRAS(keep=status survivalTIme) indsname=source;
dsn_name = source;
run;
Proc Lifetest Data=Survival Method=KM Plots=(s) Censoredsymbol= '|';
Time SurvivalTime*STATUS (1);
strata dsn_name;
run;
Thank you so much, that definitely makes sense! But for some reason when I run this code, SAS doesn't recognize my variables in the keep statement
LOG:
That was an oversight on my part, sorry! It is working now, thank you so much!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.