BookmarkSubscribeRSS Feed
tmleung
Calcite | Level 5

Hi, I am learning SAS. I am running a survival analysis using PROC LIFEREG. The categorical varialbe has 4 groups, namely 1-4. The default reference group is the last group. How can I change it to be the first group?

 

My code:

 

proc lifereg data=larynx;
class stage;
model deathtime*death(0)=stage / distribution=exponential;
run;

 

Thanks

13 REPLIES 13
Reeza
Super User

Try the ORDER  option in the PROC LIFEREG statement. 

 

 

tmleung
Calcite | Level 5

Thanks for your reply.

 

I tried this

 

proc lifereg data=larynx;
class stage/ order=data;
model deathtime*death(0)=stage / distribution=exponential;
run;

 

I also tried just 

 

class stage/ order;

 

but still didnt work. and this is what i got

 

12 class stage/ order=data;
-----
22
202
NOTE: The previous statement has been deleted.
NOTE: PROCEDURE LIFEREG used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds

NOTE: The SAS System stopped processing this step because of errors.
ERROR 22-322: Syntax error, expecting one of the following: ;, TRUNCATE.
ERROR 202-322: The option or parameter is not recognized and will be ignored.

Reeza
Super User

Re-read what I posted. 

 

Order on proc lifereg statement, not class statement. 

tmleung
Calcite | Level 5

I see....

 

proc lifereg data=larynx order=data;
class stage;
model deathtime*death(0)=stage / distribution=exponential;
run;

 

but it still uses stage 4 as my reference group, not stage 1.

 

 
Reeza
Super User

Then unfortunately you'll have to recode the variables in such a way that the last group will be your reference. 

 

Some Procs have options to change this, but it appears proc LIFEREG doesn't 😫

tmleung
Calcite | Level 5

OK... Thanks for your help. Really appreciate it.

Ksharp
Super User
class stage(ref='xxx');
Reeza
Super User

@Ksharp Unfortunately PROC LIFEREG does not support the REF= option. The only valid option is TRUNCATE, according to the documentation.

 

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_lifereg_synt...

Ksharp
Super User
Well. That is bad new. But if it is character, Padding some blank before it to make it happen.

e.x.
want have F be the last level.

if sex='M' then sex='  M';

FreelanceReinh
Jade | Level 19

Hello @tmleung,

 

I've just tested it and found that the ORDER= option of the PROC LIFEREG statement (as suggested by @Reeza) with possible values DATA, FORMATTED (the default), FREQ or INTERNAL works very well.

 

If ORDER=DATA leaves stage 4 as the reference group, this means that in your input dataset LARYNX stage 4 happens to occur last in the order of observations. So, you have two options:

 

  1. Either you sort dataset LARYNX e.g. by descending STAGE (assuming that this variable has values 1, 2, 3, 4) and then use ORDER=DATA.
    proc sort data=larynx;
    by descending stage;
    run;
  2. Or you define a format for variable STAGE such that the label of stage 1 comes last in alphabetical order and apply that format to variable STAGE in the PROC LIFEREG step (or assign it permanently in LARYNX), where you also specify ORDER=FORMATTED. Example:
    proc format;
    value stagef
    1='Stage 1';
    run;

    proc lifereg data=larynx order=formatted;
    format stage stagef.;
    class stage;
    model deathtime*death(0)=stage / distribution=exponential;
    run;

These tips can also be found in http://support.sas.com/kb/37/108.html.

tmleung
Calcite | Level 5

Thanks.  I have tried to re-order by using PROC SORT but it still takes stage 4 as the reference group.

 

I will try the PROC FORMAT method later.

 

Thanks again

FreelanceReinh
Jade | Level 19

@tmleung wrote:

...  I have tried to re-order by using PROC SORT but it still takes stage 4 as the reference group.

 


This is odd, because in an earlier post you wrote that it also used stage 4 as the reference group with ORDER=DATA, before re-sorting. Sounds like you or your computer made a mistake. 😉

 

To investigate this, you can use the same ORDER= options with PROC FREQ. The last category in PROC FREQ output should normally be the reference category used by the corresponding PROC LIFEREG step. Example:

proc freq data=larynx order=data;
tables stage;
run;
tmleung
Calcite | Level 5

You are right. I tried with SAS in another computer and ORDER=DATA works... weird...

 

Thanks so much for your help.

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 13 replies
  • 5593 views
  • 1 like
  • 4 in conversation