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 ;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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