Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
jeminjeon
Calcite | Level 5

Dear All,

 

is that possible to make a graph(plot) for a multiple linear regression model with several covariates? I'd like to make a plot after adjustment several covariates. I saw the plot of model y=x, which adjusted covariates but don't know how to make it by sas.  Anyone can provided me some idea or example?? 

 

Here is my code. Don't know which option i have to add.

 

proc reg data=aa;

model change_weight= sex age region alcohol toe_hg;

run;quit;

 

I want to make a plot of model (change_weight=toe_hg) adjusted covariates (sex, age, region).

 

 

Thanks a lot

 

5 REPLIES 5
Rick_SAS
SAS Super FREQ

SAS regression procedures such as PROC REG and PROC GLM create many plots automatically when you use

ODS GRAPHICS ON;

to turn on ods graphics. For examples, see the Getting Started examples in PROC REG.

You can control the type of graphs by using the PLOTS= option on the PROC statement.

PaigeMiller
Diamond | Level 26

In practicality, you cannot create a plot of your multiple linear regression because such a plot would have to show a surface in six dimensions, and not even SAS can produce such a six-dimensional plot. However, SAS does produce a lot of plots that can help you diagnose if the fit is a good fit or not, and produce other diagnostics as well, as explained by @Rick_SAS by using the PLOTS= option.

--
Paige Miller
PGStats
Opal | Level 21

One idea would be to create a lattice panel of graphs (using proc sgpanel) with sex as columns and regions as rows. On each graph you could show the data for a given sex and region and some fitted lines for a few select ages.

PG
PGStats
Opal | Level 21

Here is an example using the sashelp.heart dataset:

 

/* (Poor) model for predicting cholesterol */
proc glm data=sashelp.heart;
class sex smoking_status;
model cholesterol = sex ageAtStart smoking_status|weight;
store test;
run;

/* Values at which to get predictions */
data cholValues;
do sex = "Female", "Male";
    do smoking_status = "Very Heavy (> 25)", "Non-smoker", "Light (1-5)", "Moderate (6-15)", 
        "Heavy (16-25)";
        do ageAtStart = 30 to 75 by 15;
            do weight = 120 to 240 by 20;
                output;
                end;
            end;
        end;
    end;
run;
            
/* Generate the predictions */
proc plm restore=test;
score data=cholValues out=cholPred predicted=predCholesterol;
run;

/* Assemble observations and predictions in single dataset */
data cholGraph;
set sashelp.heart cholPred(rename=ageAtStart=age);
run;

proc sort data=cholGraph; by sex smoking_status age weight; run;

/* Create graph */
ods graphics / width=600 height = 1000;
proc sgpanel data=cholGraph ;
panelby sex smoking_status / layout=lattice onepanel novarname;
scatter x=weight y=cholesterol;
series x=weight y=predCholesterol / group=age  nomissinggroup 
    lineattrs=(pattern=solid);
run;

SGPanel11.png

PG
Rick_SAS
SAS Super FREQ

You can also use the EFFECTPLOT statement to visualize regression models.

The article shows how to use the EFFECTPLOT statement directly in regression procedures and how to use the STORE statement and PROC PLM to visualize the model in a post-fit analysis.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 6957 views
  • 1 like
  • 4 in conversation