BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Hello_there
Lapis Lazuli | Level 10

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
PaigeMiller
Diamond | Level 26

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.

 

Screenshot 2024-01-17 074218.png

--
Paige Miller

View solution in original post

10 REPLIES 10
PaigeMiller
Diamond | Level 26

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.

 

Screenshot 2024-01-17 074218.png

--
Paige Miller
Hello_there
Lapis Lazuli | Level 10
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.
PaigeMiller
Diamond | Level 26

@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
Hello_there
Lapis Lazuli | Level 10
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.

PaigeMiller
Diamond | Level 26

@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
Hello_there
Lapis Lazuli | Level 10
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.
PaigeMiller
Diamond | Level 26

@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
Hello_there
Lapis Lazuli | Level 10
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.
PaigeMiller
Diamond | Level 26

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
Hello_there
Lapis Lazuli | Level 10
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!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 2240 views
  • 4 likes
  • 2 in conversation