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
SAS Super FREQ

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 318 views
  • 0 likes
  • 2 in conversation