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) |
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.