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
Try the ORDER option in the PROC LIFEREG statement.
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.
Re-read what I posted.
Order on proc lifereg statement, not class statement.
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.
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 😫
OK... Thanks for your help. Really appreciate it.
@Ksharp Unfortunately PROC LIFEREG does not support the REF= option. The only valid option is TRUNCATE, according to the documentation.
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';
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:
proc sort data=larynx;
by descending stage;
run;
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.
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
@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;
You are right. I tried with SAS in another computer and ORDER=DATA works... weird...
Thanks so much for your help.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.