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

Hi, I need to calculate odds ratios, while keeping  this group of time variable as referance -(6 months to less than 12 months).

I am new to this, please check the below code and I want to make sure I am doing this correctly.

I appreciate your timely help!

Thank you.

 

proc format;
value timef 1='6 months to less than 12 months '
2='12 months to less than 24 months '
3='24 months to less than 36 months '
4='36 months and above';

value $oldf '0'='Young'
'1'='Old'
;
run;


data one;
input old $1. time;
datalines;
1 1
0 2
1 3
1 2
0 1
1 3
0 2
1 3
0 4
1 4
0 3
1 4
;
run;


data two;
set one;
format time timef.;
run;

ods graphics on;
proc logistic data=two plots(only)=(effect (clband) oddsratio (type=horizontalstat));
class time(param=ref ref="6 months to less than 12 months");
model old (event="1") = time/clodds=pl;
run;
ods graphics off;

1 ACCEPTED SOLUTION

Accepted Solutions
CiCi
Fluorite | Level 6

 

The way you put referece level looks correct to me. I tested your code. You can find a table "Class Level Information" from the output (see below). The "0-0-0" in "Design Variables" represents the reference group, which is what you specified. 

 

Be careful about your formats. Better to remove those blanks from format. Sometime, this can cause unexpected problem and can be hard to debug. 

 

Proc Format;


Value timef

1='6 months to less than 12 months '
2='12 months to less than 24 months '
3='24 months to less than 36 months '
4='36 months and above'

;

 

Value $oldf

'0'='Young'
'1'='Old'
;


run;

 

 

View solution in original post

3 REPLIES 3
CiCi
Fluorite | Level 6

 

The way you put referece level looks correct to me. I tested your code. You can find a table "Class Level Information" from the output (see below). The "0-0-0" in "Design Variables" represents the reference group, which is what you specified. 

 

Be careful about your formats. Better to remove those blanks from format. Sometime, this can cause unexpected problem and can be hard to debug. 

 

Proc Format;


Value timef

1='6 months to less than 12 months '
2='12 months to less than 24 months '
3='24 months to less than 36 months '
4='36 months and above'

;

 

Value $oldf

'0'='Young'
'1'='Old'
;


run;

 

 
CiCi
Fluorite | Level 6

BTW, I cannot attached the table due to HTML error....Try to find the table labelled as "Class Level Information".

Ksharp
Super User

use ODDSRATIO statement or 

use 

model old (event="1") = time/clodds=pl  EXP ;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 3152 views
  • 0 likes
  • 3 in conversation