## Graph Multiple Regression with 2 lines

Solved
Occasional Contributor
Posts: 9

# Graph Multiple Regression with 2 lines

Hi everyone,

I am trying to create a graph for a multiple regression (used PROC GLM to create) with 9 covariates. I want to make a graph with two lines (druguse=0 and druguse=1), plugging in for 'typical' values of the other covariates (ie, age50, race=white, etc).

Is that even possible? I am using SAS Studio.

Here's what I've done so far:

PROC SGPLOT DATA=sample.name;

SCATTER X=BASELINE Y=CHANGE/GROUP=DRUGUSE;

REG X=BASELINE Y=CHANGE/CLI CLM NOMARKERS;

RUN;

However, this REG doesn't include all my covariates! Not sure what to do!

Accepted Solutions
Solution
‎10-09-2017 03:47 PM
SAS Super FREQ
Posts: 3,898

## Re: Graph Multiple Regression with 2 lines

I do not know the valid values of your continuous variables, but try something like this:

CLASS HARD_DRUGS INCOME2;
effectplot slicefit/  at(

AGE = 30

BMI = 25

MARI = 0

ALCOHOL = 1

CSMOKER = 1

HS = 1

);

Whatever value you use on the right-hand side will determine the value at which the model is evaluated for the effectplot. The first continuous variable MODEL statement (AGG_MENT0 ) determines the continuous axis for the effect plot.

All Replies
SAS Super FREQ
Posts: 975

## Re: Graph Multiple Regression with 2 lines

Add GROUP=DRUGUSE to the REG statement as well.

Occasional Contributor
Posts: 9

## Re: Graph Multiple Regression with 2 lines

It gets really crazy ! Plus, doing that doesn't include my full model.

The full model has drug use, age, baseline score, bmi, income, high school, marijuana use, etc.

Super User
Posts: 12,148

## Re: Graph Multiple Regression with 2 lines

LGrau wrote:

It gets really crazy ! Plus, doing that doesn't include my full model.

The full model has drug use, age, baseline score, bmi, income, high school, marijuana use, etc.

Which would make that a 7+ dimension graph. We don't really have good technology for displaying 3 dimensions and you want to display more than 4 more? In a single plot?

SAS Super FREQ
Posts: 466

## Re: Graph Multiple Regression with 2 lines

Typically a regression plot with multiple lines is only made when there is a CLASS variable (although there could be more than one) and a single continuous variable--the kind of graph you made with PROC SGPLOT.  What is it you want?  How do the other variables enter in?

Occasional Contributor
Posts: 9

## Re: Graph Multiple Regression with 2 lines

My Model is this:

PROC GLM DATA=BIOS6623.AGG_MENT;
CLASS INCOME2;
MODEL DELTAAGGMENT=AGG_MENT0 HARD_DRUGS AGE BMI MARI ALCOHOL CSMOKER INCOME2 HS ADHY2_ NHW/SOLUTION CLPARM;
TITLE "MODEL 1: FULL MODEL FOR CHANGE IN AGGREGATE MENTAL SCORE FOR ALL VARIABLES";
QUIT; TITLE;

I want to create a graph with two lines (Hard_Drugs=1 and Hard_Drugs=0), with age=50 race=NHW Mari=0 alcohol=0 HS=0 ADHY2=1 CSMOKER=0, etc.

This is the code I have so far, but it is not happening.
PROC SGPLOT DATA=BIOS6623.AGG_MENT;
TITLE "CHANGE IN AGGREGATE MENTAL SCORE";
SCATTER X=AGG_MENT0 Y=DELTAAGGMENT/GROUP=HARD_DRUGS;
REG X=AGG_MENT0 Y=DELTAAGGMENT/GROUP=HARD_DRUGS CLI CLM NOMARKERS;
RUN;TITLE;

SAS Super FREQ
Posts: 466

## Re: Graph Multiple Regression with 2 lines

It might be that the EFFECT and EFFECTPLOT statements in many of the modeling procedures  (but not GLM) can do what you want.  Sorry, but I don't have time today to play with this.

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_introcom_sec...

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_introcom_sec...

SAS Super FREQ
Posts: 466

## Re: Graph Multiple Regression with 2 lines

``````ods graphics on;
proc orthoreg data=sashelp.class;
class sex;
effectplot slicefit;
model weight = height age sex;
run;``````

See if this gets you going in the right direction.  I hope this helps.

SAS Super FREQ
Posts: 3,898

## Re: Graph Multiple Regression with 2 lines

For a discussion and examples of using the EFFECTPLOT statement to slice and dice high-dimensional regression models, see "Use the EFFECTPLOT statement to visualize regression models in SAS."

Occasional Contributor
Posts: 9

## Re: Graph Multiple Regression with 2 lines

This worked! However, it fits de line using the means of the covariates. Is there a way to fit with me specifying which values to use?

SAS Super FREQ
Posts: 3,898

## Re: Graph Multiple Regression with 2 lines

Yes. My blog post links to the documentation. You might want to look at the AT= option.

You can specify statistics (mean, min, max, midrange) or specify particular values:

`effectplot / at(x=min max x=2 5 7);`
Occasional Contributor
Posts: 9

## Re: Graph Multiple Regression with 2 lines

That gives me the error "VARIABLE CONFIGURATION IS NOT CURRENTLY SUPPORTED BY THE EFFECTPLOT STATEMENT"

SAS Super FREQ
Posts: 3,898

## Re: Graph Multiple Regression with 2 lines

Please post your code and specify what version of SAS you are running.

Occasional Contributor
Posts: 9

## Re: Graph Multiple Regression with 2 lines

I'm using SAS Studio!

ods graphics on;
proc orthoreg data=BIOS6623.AGG_MENT;
CLASS HARD_DRUGS INCOME2;
effectplot slicefit/ cli clm;
model DELTAAGGMENT=AGG_MENT0 HARD_DRUGS AGE BMI MARI ALCOHOL CSMOKER INCOME2 HS ADHY2_ NHW;
run;

proc orthoreg data=BIOS6623.AGG_PHYS;
CLASS HARD_DRUGS INCOME2;
effectplot slicefit/ cli clm;
model DELTAAGGPHYS=AGG_PHYS0 HARD_DRUGS AGE BMI MARI ALCOHOL CSMOKER INCOME2 HS ADHY2_ NHW;
run;

proc orthoreg data=BIOS6623.LEU3N;
CLASS HARD_DRUGS INCOME2;
effectplot slicefit/ cli clm;
model DELTALEU3N=LEU3N0 HARD_DRUGS AGE BMI MARI ALCOHOL CSMOKER INCOME2 HS ADHY2_ NHW ;
run;

CLASS HARD_DRUGS INCOME2;
effectplot slicefit/ cli clm;
run;

SAS Super FREQ
Posts: 3,898

## Re: Graph Multiple Regression with 2 lines

SAS Studio is an interface. It does not tell me what version of SAS you are using by running

`%put SYSVLONG = &SYSVLONG;`

The examples you posted do not use the AT= option. Please post the code that is giving the error, along with the portion of the SAS log that shows the error messages.

☑ This topic is solved.