Programming the statistical procedures from SAS

How to change the reference group in PROC LIFEREG?

Reply
Occasional Contributor
Posts: 9

How to change the reference group in PROC LIFEREG?

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

Grand Advisor
Posts: 16,908

Re: How to change the reference group in PROC LIFEREG?

Try the ORDER  option in the PROC LIFEREG statement. 

 

 

Occasional Contributor
Posts: 9

Re: How to change the reference group in PROC LIFEREG?

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.

Grand Advisor
Posts: 16,908

Re: How to change the reference group in PROC LIFEREG?

Re-read what I posted. 

 

Order on proc lifereg statement, not class statement. 

Occasional Contributor
Posts: 9

Re: How to change the reference group in PROC LIFEREG?

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.

 

 
Grand Advisor
Posts: 16,908

Re: How to change the reference group in PROC LIFEREG?

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 😫

Occasional Contributor
Posts: 9

Re: How to change the reference group in PROC LIFEREG?

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

Grand Advisor
Posts: 9,458

Re: How to change the reference group in PROC LIFEREG?

class stage(ref='xxx');
Grand Advisor
Posts: 16,908

Re: How to change the reference group in PROC LIFEREG?

@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...

Grand Advisor
Posts: 9,458

Re: How to change the reference group in PROC LIFEREG?

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';

Trusted Advisor
Posts: 1,114

Re: How to change the reference group in PROC LIFEREG?

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.

Occasional Contributor
Posts: 9

Re: How to change the reference group in PROC LIFEREG?

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

Trusted Advisor
Posts: 1,114

Re: How to change the reference group in PROC LIFEREG?


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;
Occasional Contributor
Posts: 9

Re: How to change the reference group in PROC LIFEREG?

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

 

Thanks so much for your help.

Ask a Question
Discussion stats
  • 13 replies
  • 355 views
  • 0 likes
  • 4 in conversation