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

Hi all,

I wanted to get the grouping variable in order on the figures generated for the CIF curves using the %newsurv macro. I want the controls on top row, then AP CP and APCP. However, when I use CLASSORDER 1 2 3 4, the display on the curve is still going by alphabetical order and not by the order on the macro. For both the legend on the top left and for the Patients-at-risk at the bottom, I want Controls on the top row followed by AP, CP and APCP.

 

I noticed that the CLASSREF goes by the formatted value Controls and not by 1 and the CLASSORDER goes by 1 2 3 4 and not by Controls AP CP APCP.

 

 

I would really appreciate any help with this.

 

I used the macro and the template examples from the link below.

 

https://communities.sas.com/t5/SAS-Communities-Library/Kaplan-Meier-Survival-Plotting-Macro-NEWSURV/...

2_Color_New.png

proc format;
   value grpLabel 1='Controls' 2='AP' 3='CP' 4='APCP';
run;
 
data three;
Set Two;
        format Group grpLabel.;
if SmokEFS = 0 then Group = 1;
else if SmokEFS = 1 then Group = 2;
else if SmokEFS = 2 then Group = 3;
else if SmokEFS = 3 then Group = 4;
run;

 %newsurv(DATA=three, TIME=dur, CENS=PDAC, CEN_VL=0, SUMMARY=0, CLASS=Group, CLASSREF=Controls, CLASSORDER=1 2 3 4,
    COLOR=black red green blue, PATTERN=solid, LINESIZE=3pt, SYMBOLSIZE=10pt,
     METHOD=CIF, EV_VL=1);  

 

1 ACCEPTED SOLUTION

Accepted Solutions
unison
Lapis Lazuli | Level 10

The ordering is based on the formatted levels (i.e. alphabetic is what's shown as 1=AP, 2=APCP, 3=CP, 4=Controls).

You can either adjust your format as:

proc format;
   value grpLabel 1='01Controls' 2='02AP' 3='03CP' 4='04APCP';
run;

But I guarantee you don't want this because of the appearance on the graph.

 

Instead, change your %new_surv call as the following:

%newsurv(DATA=three, TIME=dur, CENS=PDAC, CEN_VL=0, SUMMARY=0, CLASS=Group, 
	CLASSREF=Controls, CLASSORDER=4 1 3 2, COLOR=black red green blue, 
	PATTERN=solid, LINESIZE=3pt, SYMBOLSIZE=10pt, METHOD=CIF, EV_VL=1);

Note the 4 1 3 2 matches the label order that you want (as above 4=Controls, 1=AP, 3=CP 2=APCP).

 

Hope this helps

-unison

View solution in original post

2 REPLIES 2
unison
Lapis Lazuli | Level 10

The ordering is based on the formatted levels (i.e. alphabetic is what's shown as 1=AP, 2=APCP, 3=CP, 4=Controls).

You can either adjust your format as:

proc format;
   value grpLabel 1='01Controls' 2='02AP' 3='03CP' 4='04APCP';
run;

But I guarantee you don't want this because of the appearance on the graph.

 

Instead, change your %new_surv call as the following:

%newsurv(DATA=three, TIME=dur, CENS=PDAC, CEN_VL=0, SUMMARY=0, CLASS=Group, 
	CLASSREF=Controls, CLASSORDER=4 1 3 2, COLOR=black red green blue, 
	PATTERN=solid, LINESIZE=3pt, SYMBOLSIZE=10pt, METHOD=CIF, EV_VL=1);

Note the 4 1 3 2 matches the label order that you want (as above 4=Controls, 1=AP, 3=CP 2=APCP).

 

Hope this helps

-unison
sms1891
Quartz | Level 8

Thanks for the response to my question. I had figured it out and it is on the macro description of the original macro code.

 

CLASSORDER = List of numbers corresponding to the preferred order of the

|              alphabetically sorted class variable formatted values.

|              Example: Values = A, B, C.  CLASSORDER = 2 1 3 would cause

|              order to be B, A, C.

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 724 views
  • 0 likes
  • 2 in conversation