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:
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!
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) |
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.