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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

4 REPLIES 4
Reeza
Super User

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;

kmardinian
Quartz | Level 8

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:

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 PROC IMPORT DATAFILE="/folders/myshortcuts/SAS_filesUSB/ConcordantKRAS.xlsx"
63 OUT=ConKRAS
64 DBMS=XLSX
65 REPLACE;
66
 
NOTE: The import data set has 380 observations and 26 variables.
NOTE: WORK.CONKRAS data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.15 seconds
cpu time 0.13 seconds
 
67 PROC IMPORT DATAFILE="/folders/myshortcuts/SAS_filesUSB/DiscordantKRAS.xlsx"
 
68 OUT=DisKRAS
69 DBMS=XLSX
70 REPLACE;
71 run;
 
NOTE: The import data set has 528 observations and 26 variables.
NOTE: WORK.DISKRAS data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.18 seconds
cpu time 0.18 seconds
 
 
72
73 Data Survival;
74 Set ConKRAS (Keep= status SurvivalTime) diskRAS(keep=status survivalTIme) indsname=source;
ERROR: The variable status in the DROP, KEEP, or RENAME list has never been referenced.
75 dsn_name = source;
76 run;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SURVIVAL may be incomplete. When this step was stopped there were 0 observations and 3 variables.
WARNING: Data set WORK.SURVIVAL was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
77
78 Proc Lifetest Data=Survival Method=KM Plots=(s) Censoredsymbol= '|';
79 Time SurvivalTime*STATUS (1);
80 strata dsn_name;
ERROR: Variable DSN_NAME not found.
81 run;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE LIFETEST used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
82
83 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
96
 
Do you know why that is? Thank you!
Reeza
Super User
72
73 Data Survival;
74 Set ConKRAS (Keep= status SurvivalTime) diskRAS(keep=status survivalTIme) indsname=source;
ERROR: The variable status in the DROP, KEEP, or RENAME list has never been referenced.
75 dsn_name = source;
76 run;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SURVIVAL may be incomplete. When this step was stopped there were 0 observations and 3 variables.
WARNING: Data set WORK.SURVIVAL was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
I used the code you provided, which indicated the variable names was 'status' in both data sets. If your code ran before it should run now, but this is a variable name issue. You can verify the variable names and ensure that you have the correct names and variables to combine the data - they need to be the same type to be able to combine it. 
 
 
kmardinian
Quartz | Level 8

That was an oversight on my part, sorry! It is working now, thank you so much!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1985 views
  • 0 likes
  • 2 in conversation