Turn on suggestions

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

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- How do i output odds ratios and confident intervals into a data set fr...

Options

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

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 01-17-2024 07:08 AM
(890 views)

Hi,

I'm having difficulty outputting the C.I.'s and odds ratios into a data set, could someone give me advice on how to do that?

```
proc genmod data=have descending;
by visit;
class trt loc;
model outcome = trt age loc;
lsmeans trt/ diff cl ilink oddsratio;
run;
```

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The general method of finding the table name for ODS OUTPUT, that works for any PROC, not just GENMOD, is to run the code with ODS TRACE ON;

```
ods trace on;
proc glm data=sashelp.class;
class sex;
model height=age weight sex/solution;
run; quit;
ods trace off;
```

You will see this in the log, and so the table name of each part of the output can be found in this log output next to "Name:"

```
Output Added:
-------------
Name: ClassLevels
Label: Class Levels
Template: STAT.GLM.ClassLevels
Path: GLM.Data.ClassLevels
-------------
Output Added:
-------------
Name: NObs
Label: Number of Observations
Template: STAT.GLM.NObsNotitle
Path: GLM.Data.NObs
-------------
Output Added:
-------------
Name: OverallANOVA
Label: Overall ANOVA
Template: stat.GLM.OverallANOVA
Path: GLM.ANOVA.Height.OverallANOVA
-------------
Output Added:
-------------
Name: FitStatistics
Label: Fit Statistics
Template: stat.GLM.FitStatistics
Path: GLM.ANOVA.Height.FitStatistics
-------------
Output Added:
-------------
Name: ModelANOVA
Label: Type I Model ANOVA
Template: stat.GLM.Tests
Path: GLM.ANOVA.Height.ModelANOVA
-------------
Output Added:
-------------
Name: ModelANOVA
Label: Type III Model ANOVA
Template: stat.GLM.Tests
Path: GLM.ANOVA.Height.ModelANOVA
-------------
Output Added:
-------------
Name: ParameterEstimates
Label: Solution
Template: stat.GLM.Estimates
Path: GLM.ANOVA.Height.ParameterEstimates
-------------
```

In this case, you could obtain the parameter estimates by using table name ParameterEstimates

`ods output parameterestimates=parms;`

Alternative method:

For specific PROCs, like GENMOD, you can go into the SAS documentation for that PROC, and click on Details, then select ODS Table Names to see a list of what table names are available, and you can then select the one you want.

--

Paige Miller

Paige Miller

10 REPLIES 10

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The general method of finding the table name for ODS OUTPUT, that works for any PROC, not just GENMOD, is to run the code with ODS TRACE ON;

```
ods trace on;
proc glm data=sashelp.class;
class sex;
model height=age weight sex/solution;
run; quit;
ods trace off;
```

You will see this in the log, and so the table name of each part of the output can be found in this log output next to "Name:"

```
Output Added:
-------------
Name: ClassLevels
Label: Class Levels
Template: STAT.GLM.ClassLevels
Path: GLM.Data.ClassLevels
-------------
Output Added:
-------------
Name: NObs
Label: Number of Observations
Template: STAT.GLM.NObsNotitle
Path: GLM.Data.NObs
-------------
Output Added:
-------------
Name: OverallANOVA
Label: Overall ANOVA
Template: stat.GLM.OverallANOVA
Path: GLM.ANOVA.Height.OverallANOVA
-------------
Output Added:
-------------
Name: FitStatistics
Label: Fit Statistics
Template: stat.GLM.FitStatistics
Path: GLM.ANOVA.Height.FitStatistics
-------------
Output Added:
-------------
Name: ModelANOVA
Label: Type I Model ANOVA
Template: stat.GLM.Tests
Path: GLM.ANOVA.Height.ModelANOVA
-------------
Output Added:
-------------
Name: ModelANOVA
Label: Type III Model ANOVA
Template: stat.GLM.Tests
Path: GLM.ANOVA.Height.ModelANOVA
-------------
Output Added:
-------------
Name: ParameterEstimates
Label: Solution
Template: stat.GLM.Estimates
Path: GLM.ANOVA.Height.ParameterEstimates
-------------
```

In this case, you could obtain the parameter estimates by using table name ParameterEstimates

`ods output parameterestimates=parms;`

Alternative method:

For specific PROCs, like GENMOD, you can go into the SAS documentation for that PROC, and click on Details, then select ODS Table Names to see a list of what table names are available, and you can then select the one you want.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks for showing me this, i tried to look at the documentation to see if there was a way to output the exponentiated odds ratios, but i didn't see anything. I assume there's no way to directly output the OR's and the C.I.'s, so i have to just exponentiate them in a separate data step.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@Hello_there wrote:

Thanks for showing me this, i tried to look at the documentation to see if there was a way to output the exponentiated odds ratios, but i didn't see anything. I assume there's no way to directly output the OR's and the C.I.'s, so i have to just exponentiate them in a separate data step.

Is this a new question? You didn't mention exponentiated odds ratio initially. Yes, the methods I provided above will allow you to get output of Odds Ratios into a SAS data set. Whatever output you want can be directed to a SAS data set.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Haha, technically yes it's a new question. But since it's related to the premise of the topic, i guess i needed confirmation to see that in order to obtain the OR's and C.I.'s i'd have to exponentiate the parameter estimates.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@Hello_there wrote:

Haha, technically yes it's a new question. But since it's related to the premise of the topic, i guess i needed confirmation to see that in order to obtain the OR's and C.I.'s i'd have to exponentiate the parameter estimates.

I don't think you have to do that. The ILINK option ought to do that for you.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

It shows the OR's in the output window, but i have to manually exponentiate them in the data set in order to get them into a table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@Hello_there wrote:

It shows the OR's in the output window, but i have to manually exponentiate them in the data set in order to get them into a table.

Let's work on one question at a time. Let's just forget exponentiated odds ratios for now. Did you try any of the methods I suggested to get the odds ratio into a SAS data set?

Now that I think about it, exponentiated odds ratios seems like it is something that doesn't exist, and that's why you don't see them; exponentiated LSMEANS is what the ILINK option is producing.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

i think i may have said things that were confusing, so i'll back up.

My main goal was to find a way to output OR's and their CI's into a data set. Your original answer directed me to find out the name of the table they belong to using ODS TRACE ON option, and i was able to get parameter estimates outputting into a data set.

Using the ODDSRATIO statement in my original code produced an output window that shows the models information, including ODDS RATIOS, PVALUES, and CONFIDENCE INTERVALS of the OR's. But outputting the data set does not include the OR's. What is included is the parameter estimates. They need to be exponentiated in order to turn into OR's, and same method applies to the C.I.'s.

I did find my answer, but as far as being able to skip the step where i output the OR's without having to exponentiate the parameter estimates to get them in a separate data step, that is not possible i believe.

My main goal was to find a way to output OR's and their CI's into a data set. Your original answer directed me to find out the name of the table they belong to using ODS TRACE ON option, and i was able to get parameter estimates outputting into a data set.

Using the ODDSRATIO statement in my original code produced an output window that shows the models information, including ODDS RATIOS, PVALUES, and CONFIDENCE INTERVALS of the OR's. But outputting the data set does not include the OR's. What is included is the parameter estimates. They need to be exponentiated in order to turn into OR's, and same method applies to the C.I.'s.

I did find my answer, but as far as being able to skip the step where i output the OR's without having to exponentiate the parameter estimates to get them in a separate data step, that is not possible i believe.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Please show me the LSMEANS output. Please show me the ODS TRACE OUTPUT. Please show me the SAS data set created by ODS OUTPUT of the LSMEANS output.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks for being willing to work it out for me, but i don't have a dummy data set that i could use my code on to post the requested outputs.

I confirm what i found what i'm looking for, and your solution helped.

Thanks!

I confirm what i found what i'm looking for, and your solution helped.

Thanks!

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.