BookmarkSubscribeRSS Feed
Dinesh2
Calcite | Level 5
Hello, does anyone know how to output the graphics in proc surveylogistic. For example, the odds ratio output as in this url : https://blogs.sas.com/content/iml/files/2015/07/oddsratio2.png. Thank you.
4 REPLIES 4
Reeza
Super User

What do you mean by output? 

Do you mean get it to appear in the results or do you mean save the graph to a PDF or PNG file? or something else?

 


@Dinesh2 wrote:
Hello, does anyone know how to output the graphics in proc surveylogistic. For example, the odds ratio output as in this url : https://blogs.sas.com/content/iml/files/2015/07/oddsratio2.png. Thank you.

 

Dinesh2
Calcite | Level 5

I am only getting the tables after running the surveylogistic command. Not the figure. 

Here's my command:

 

proc surveylogistic data=afib14lg ;

    weight DISCWT ;

cluster HOSP_NIS ;

strata NIS_STRATUM ;

class chronic (param=ref ref='0')

died (param=ref ref='0')pay1 (param=ref ref='1') female (param=ref ref='0')

aweekend (param=ref ref='0') hosp_locteach  (param=ref ref='1')  race (param=ref ref='1')  ;

model died= chronic aweekend los pay1 female  race elixci  hosp_locteach;

run;

 

Thank you.

Reeza
Super User

Unfortunately not seeing a default way from SurveyLogistic which is weird given that it's pretty developed. Hopefully I'm wrong, I'll move the question to Stats Procs forum and hopefully someone else can clarify. 

 

Anyways, here's a workaround for now. This is from the example in the docs and you may need slightly modifications for your data. 

The graph code is from the same link as in your original post and the PROC code is from the documentation.  Basically, I capture the OddsRatio estimates and plot them in a new procedure. I do have to create a variable that includes all the levels in a single variable. 

 

/*-----------------------------------------------------------------
S A S   S A M P L E   L I B R A R Y

NAME: SVLEX1
TITLE: Documentation Example 1 for PROC SURVEYLOGISTIC
PRODUCT: STAT
SYSTEM: ALL
KEYS: logistic regression, survey sampling
KEYS: link functions, stratification, clustering
KEYS: unequal weighting, categorical data analysis
PROCS: SURVEYLOGISTIC
DATA:

SUPPORT: sasaba
REF: PROC SURVEYLOGISTIC, Example 1

MISC: Logistic Regression with Different Link
Functions for Stratified Cluster Sampling
-----------------------------------------------------------------*/
proc format;
    value Class 1='Freshman' 2='Sophomore' 3='Junior' 4='Senior';
run;

data Enrollment;
    format Class Class.;
    input Class _TOTAL_;
    datalines;
1 3734
2 3565
3 3903
4 4196
;

proc format;
    value Design 1='A' 2='B' 3='C';
    value Rating 1='dislike very much' 2='dislike' 3='neutral' 4='like' 
        5='like very much';
run;

data WebSurvey;
    format Class Class. Design Design. Rating Rating.;

    do Class=1 to 4;

        do Design=1 to 3;

            do Rating=1 to 5;
                input Count @@;
                output;
            end;
        end;
    end;
    datalines;
10 34 35 16 15   8 21 23 26 22   5 10 24 30 21
 1 14 25 23 37  11 14 20 34 21  16 19 30 23 12
19 12 26 18 25  11 14 24 33 18  10 18 32 23 17
 8 15 35 30 12  15 22 34  9 20   2 34 30 18 16
;

data WebSurvey;
    set WebSurvey;

    if Class=1 then
        Weight=3734/300;

    if Class=2 then
        Weight=3565/300;

    if Class=3 then
        Weight=3903/300;

    if Class=4 then
        Weight=4196/300;
run;

proc print data=WebSurvey(obs=20);
run;

ods output oddsRatios=plotData;

proc surveylogistic data=WebSurvey total=Enrollment;
    stratum Class;
    freq Count;
    class Design;
    model Rating (ref='neutral')=Design /link=glogit;
    weight Weight;
run;

*add levels in to YVar so that data is plotted correctly;
data demo;
    set plotData;
    YVar=catx(' - ', effect, Response);
run;


*example from: https://blogs.sas.com/content/iml/2015/07/29/or-plots-log-scale.html;
title "Odds Ratios with 95% Wald Confidence Limits";

proc sgplot data=demo noautolegend;
    scatter y=yVar x=OddsRatioEst / xerrorlower=LowerCL xerrorupper=UpperCL 
        markerattrs=(symbol=diamondfilled);
    refline 1 / axis=x;
    xaxis grid type=log label="Odds Ratio (log scale)";

    /* specify log scale */
    yaxis grid display=(nolabel) discreteorder=data reverse;
run;

@Dinesh2 wrote:

I am only getting the tables after running the surveylogistic command. Not the figure. 

Here's my command:

 

proc surveylogistic data=afib14lg ;

    weight DISCWT ;

cluster HOSP_NIS ;

strata NIS_STRATUM ;

class chronic (param=ref ref='0')

died (param=ref ref='0')pay1 (param=ref ref='1') female (param=ref ref='0')

aweekend (param=ref ref='0') hosp_locteach  (param=ref ref='1')  race (param=ref ref='1')  ;

model died= chronic aweekend los pay1 female  race elixci  hosp_locteach;

run;

 

Thank you.


 

Dinesh2
Calcite | Level 5

That's what I thought after doing an extensive online search about proc surveylogistic.

Anyways, I tried your code and it did work. Thank you so much for your help. 

 

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2372 views
  • 0 likes
  • 2 in conversation