BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
turcay
Lapis Lazuli | Level 10

Hello everyone,

 

I’m on a project now which is related to pharmaceutical industry. I’m trying to change the legend label of the PROC LIFETEST procedure’s graph result. As you can see the following image, the legend labels seem as Kras=-1 Kras=0 Kras=1 however I need to see the reports as  Unknown(Kras=-1), Negative(Kras=0)  and Positive(Kras=1). I prepared a sample data set that does not express anything and I’m sharing with you that sample data set as below. How can I see the legend label’s as Unknown , Negative and Positive. Does anybody can lead me, please ?

 

DATA Have;
Length AVAL 8 KRAS 8;
Infile Datalines Missover;
Input AVAL KRAS ;
Datalines;
80 1
34 1
391 1
221 0
362 0
219 0
113 0
48 1
105 1
18 1
54 1
333 1
172 -1
235 0
81 0
;
Run;

PROC LIFETEST DATA=Have
	ALPHA=0.05
	METHOD=LIFE
	INTERVALS= 30 60 90 120 150 180	PLOTS(ONLY)=SURVIVAL ( STRATA=UNPACK );;
	STRATA KRAS;
	TIME AVAL;
RUN;

 

 

 

Thank you.


Desired.png
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Here's a post with an example of it being used 😉

The original question includes the proc format and it's used in the graphing procedure, though it's applied through proc datasets first. That isn't necessary, it can be applied directly in the statistical procedure.

 

https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/How-To-Show-Variables-Legendlabel-and-Medi...

View solution in original post

10 REPLIES 10
Jay54
Meteorite | Level 14

Please tell us the release of SAS you are using and if you are willing to write your own program to create the graph.  If yes, do you prefer SGPLOT or GTL?

Reeza
Super User

Have you tried creating a format and applying a format to the variable in the proc lifetest procedure?

turcay
Lapis Lazuli | Level 10

As far as I understand there are not any options to change the legend label in PROC LIFETEST. @Jay54, I'm out office at the moment but I remember the release of SAS as 9.3 . Actually, I'm willing to change the legend label and If is it possible by the help of the GTL or GPLOT, I can write it. @Reeza No, I haven't tried creating a format and applying a format to the variable in the PROC LIFETEST procedure. Could you lead me to reach my aim, please ?

 

Thank you.

Reeza
Super User

Your code doesn't seem to match your graph. Is that your actual proc lifetest?

 

Applying a format does change your legend

 

1. Create a format that maps your numbers to the text you want. Assume you call it kras_fmt.

See this paper.

 

2. Change your proc lifetest by adding the following line to your code, again assuming you've called it kras_fmt.

format kras kras_fmt.;

 

 

turcay
Lapis Lazuli | Level 10

Hello @Reeza ,

 

No, it isn't my actual PROC LIFETEST. I wrote this code to make easier to share with you. I didn't see any paper. Am I missing something ?

 

Thanks.

Reeza
Super User

Here's a post with an example of it being used 😉

The original question includes the proc format and it's used in the graphing procedure, though it's applied through proc datasets first. That isn't necessary, it can be applied directly in the statistical procedure.

 

https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/How-To-Show-Variables-Legendlabel-and-Medi...

turcay
Lapis Lazuli | Level 10

Thank you @Reeza, The following code is working . After you adviced me the Proc Format I was trying to find my Box-Whisker . How can you find it ? But I want to ask one more question, apart from Proc Format is there any method to create my desired output ? Let me check on customer place . If it works there then I'll close this discussion. 

 

Thanks.

 

 


proc format;
value Kras_fmt
-1='Negative'
0='Unknown'
1='Positive'
;
run;
PROC LIFETEST DATA=Have
     ALPHA=0.05
     METHOD=LIFE
     INTERVALS= 30 60 90 120 150 180 PLOTS(ONLY)=SURVIVAL ( STRATA=UNPACK );
    Format Kras Kras_fmt.;
     STRATA KRAS;
     TIME AVAL;
RUN;

 

Reeza
Super User

Other options:

1. Recode variable into a character variable directly

2. Extract Data from proc lifetest and use a graphic procedure

3. Look at macro suggestions from SAS in documentation to modify survival curves.

 

How did I find your post? Search term: PROC FORMAT Limit by User on left hand menu to Turcay.

turcay
Lapis Lazuli | Level 10

@Reeza, Thank you for the information, I will try the other options as soon as possible.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 10 replies
  • 5582 views
  • 0 likes
  • 3 in conversation