BookmarkSubscribeRSS Feed
tofov2
Calcite | Level 5

Hello everyone,

 

I have obtained crude odds ratios and confidence intervals for several variables using prog logistic and ods output. The code for how I obtained these values is below.

 

 

ods output GlobalTests(persist=proc)=glt(where=(test=:'L'))
ParameterEstimates(persist=proc)=est
OddsRatios(persist=proc)=odr;

 

proc logistic data=newexcel order=formatted;
class response &Covar;
format &newformats;
model Response(ref='Nonresponder')= &Covar ; run;

ods output close;

 

data odr2;
set odr;
informat oddsratioest 8.2 lowerCL 8.2 uppercl 8.2;
format oddsratioest 8.2 lowerCL 8.2 uppercl 8.2;
drop _:;
run;

 

Next, I would to have the odds ratios (OddsRatioEst) and confidence intervals (LowerCL UpperCL) combined into one cell, with a 8.2 format for each value and have them include parentheses and a comma into a single cell to make easier for placement into a different table.

 

Essentially, take the below:

 

Screen Shot 2022-12-08 at 9.14.57 AM.png

 

And format it to look like

 

Sex Female vs Male       0.91 (0.61, 1.35)

 

Ideally, 0.91 (0.61, 1.35) would all be house in a single column.

 

Thanks in advanced for any help!

1 REPLY 1
SASJedi
Ammonite | Level 13

Instead of this:

 

data odr2;
   set odr;
   informat oddsratioest 8.2 lowerCL 8.2 uppercl 8.2;
   format oddsratioest 8.2 lowerCL 8.2 uppercl 8.2;
   drop _:;
run;

Try this:

 

 

data odr2;
	set odr;
	length Odds $50;
	Odds=cat(put(oddsratioest,4.2),' (',catx(', ', put(lowerCL,4.2), put(uppercl,4.2)),')');
	Keep Effect Odds;
run;

This should produce:

Obs Effect Odds
1 Sex Female vs. Male  0.91 (0.61, 1.35)
2 Active_smoke yes vs no 0.88 (0.47, 1.66)
 ... … ... 
7 CKD yes vs no 0.74 (0.46, 1.18)

 

 

Check out my Jedi SAS Tricks for SAS Users

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 1 reply
  • 1407 views
  • 0 likes
  • 2 in conversation