turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- How to export odds ratios, confidence interval and...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-20-2017 03:28 PM

Hi,

I wrote a macro for univariate logistic regression analysis. How do I export the odds ratio, 95% C.I. and p-value from each of the below model? Should I add ods output statement in the macro? Thank you!

%macro CDR_diff(x=);

proc logistic data=cdr_df1;

class &x;

where visitnum=1;

model cdr_dfcat2= &x / expb;

run;

%mend CDR_diff;

%CDR_diff(x=sex);

%CDR_diff(x=ethnic1);

%CDR_diff(x=race1);

%CDR_diff(x=smoke2);

%CDR_diff(x=alcohol1);

%CDR_diff(x=marital1);

%CDR_diff(x=educ1);

%CDR_diff(x=employ1);

%CDR_diff(x=educ_yrs1);

%CDR_diff(x=income1);

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Denali

11-20-2017 03:39 PM

Use ODS TRACE on before your PROC LOGISTIC and see what output you want the underlying data from and use ODS OUTPUT on the relevant output.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Denali

11-20-2017 03:39 PM

Should I add ods output statement in the macro?

Yes, and you should look at the PERSIST option within that.

Here's a very related question that was recently posted:

Denali wrote:

Hi,

I wrote a macro for univariate logistic regression analysis. How do I export the odds ratio, 95% C.I. and p-value from each of the below model? Should I add ods output statement in the macro? Thank you!

%macro CDR_diff(x=);

proc logistic data=cdr_df1;

class &x;

where visitnum=1;

model cdr_dfcat2= &x / expb;

run;

%mend CDR_diff;

%CDR_diff(x=sex);

%CDR_diff(x=ethnic1);

%CDR_diff(x=race1);

%CDR_diff(x=smoke2);

%CDR_diff(x=alcohol1);

%CDR_diff(x=marital1);

%CDR_diff(x=educ1);

%CDR_diff(x=employ1);

%CDR_diff(x=educ_yrs1);

%CDR_diff(x=income1);

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

11-20-2017 04:18 PM

Hi,

I successfully output the odds ratio and confidence interval for the individual model using the "ods output OddsRatios(persist)=Oddsratio ModelInfo(persist)=mf;" statement.

But everytime I ran another predictor variable or another model, the odds ratio in the out was replaced. How do I keep all the odds ratios in one output file? For example, I need to run 10 models. How do I keep all 10 odds ratios and confidence intervals in the oddsratio file?

ods trace on;

%macro CDR_diff(x=);

ods output OddsRatios(persist)=Oddsratio ModelInfo(persist)=mf;

proc logistic data=cdr_df1;

class &x;

where visitnum=1;

model cdr_dfcat2= &x / expb;

run;

ods output close;

%mend CDR_diff;

%CDR_diff(x=sex);

%CDR_diff(x=ethnic1);

%CDR_diff(x=race1);

%CDR_diff(x=smoke2);

%CDR_diff(x=alcohol1);

%CDR_diff(x=marital1);

%CDR_diff(x=educ1);

%CDR_diff(x=employ1);

%CDR_diff(x=educ_yrs1);

%CDR_diff(x=income1);

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Denali

11-20-2017 04:21 PM

Review the options for PERSIST.

And, have you considered transposing your data and just using a BY with a single PROC LOGISTIC call? Seems more efficient to me.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

11-20-2017 04:40 PM - edited 11-20-2017 04:41 PM

Hi,

I tried the transpose statement but it did not work. Could you please check my code? Thank you!

%macro CDR_diff(y=);

ods output OddsRatios(persist)=ORCI ModelInfo(persist)=mf;

proc logistic data=cdr_df1;

class &y;

where visitnum=12;

model cdr_dfcat2= &y / expb;

run;

proc transpose data=ORCI out=Odds;

by &y;

run;

ods output close;

%mend CDR_diff;

%CDR_diff(y=sex);

%CDR_diff(y=ethnic1);

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Denali

11-20-2017 05:15 PM

That's not what I meant.

I mean, transpose your data before the logistic regression and then use a single PROC LOGISTIC.

Here's a blog post that details the approach.

It's really a better way to go.

https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html