BookmarkSubscribeRSS Feed
Heejeong
Obsidian | Level 7

Hello,

 

I currently have a simple PROC GLM where I am predicting levels of Norepinephrine (Norepinephrine) with stress reactivity (PAreactpost). I am using a continuous stress reactivity predictor variable in the main analysis model (PAreactpost) but want to graph the results so that the figure shows the association between "norepinephrine" and  "percentage increases of stress reactivity." We are trying to do this so that it's easier to meaningfully interpret the results. 

 

In the syntax below, I am using MARGINS MACRO to graph the figure at 1-SD, Mean, 1+SD of the stress reactivity variable. If there is a way to change this to percentages, I would greatly appreciate your help. 

 

 

proc glm data= JH.Final3;format _all_;
model Norepinephrine = cage marriedMidus cHHtotalIncome Exercise20mins cChronCondNumb ClinicSex  EverSmokeReg  race_orig CNSmeds cCESD cBMI cAnyStressWide_sum  cNeuroticism pa_mlm2 PAreactpost;
run;quit;
******USING MACRO******;
ods pdf file="C:\Users\Daesik hong\Dropbox\@Norepinephrine paper & Affect Reactivity/PAReact.pdf";
proc means data=JH.Final3;
var cPAreactpost; 
output out=out mean=mean std=sd;
run;
data mdat;
set out;
keep cPAreactpost;
do cPAreactpost = mean-sd, mean, mean+sd;
output;
end;
run;
%Margins(data=JH.Final3, response=Norepinephrine, model=cage ClinicSex marriedmidus work race_orig  cedu cHHtotalIncome EverSmokeReg Exercise20mins CNSmeds cBMI cCESD cNeuroticism  cChronCondNumb  cAnyStressWide_sum pa_mlm2 cPAreactpost,
margins=cPAreactpost, margindata=mdat,
options=diff reverse cl)

proc sort data=_margins; 
by cPAreactpost;
run;

proc sgplot data=_margins noautolegend;
band upper=UPPER lower=LOWER x=cPAreactpost ;*/ transparency=.3;
series y=ESTIMATE x=cPAreactpost;
xaxis values=(-0.0627096 0 0.0627096) grid offsetmin=.05 offsetmax=.05
label="Positive Affective Responsivity";
yaxis values=(10 to 40  by 5) grid offsetmin=.05 offsetmax=.05 
label="Norepinephrine";
title "Effects of Positive Affective Responsivity on Norepinephrine";
run;

 

 

3 REPLIES 3
Rick_SAS
SAS Super FREQ

> In the syntax below, I am using MARGINS MACRO to graph the figure at 1-SD, Mean, 1+SD of the stress reactivity variable. If there is a way to change this to percentages, I would greatly appreciate your help. 

 

I'm sorry, but I do not understand what you are trying to change to percentages. What does the word 'this' refer to?

 

Since you have not provided any data, perhaps you could upload the graph that you are currently getting and then tell us what part of the graph you want to change.

Heejeong
Obsidian | Level 7

Thank you so much for following up with my question, I definitely want to clarify my question if it was confusing!

 For clarification, I've attached several additional materials:

1. Macro Margins syntax, and the final dataset. 

2. Syntax that generated the final figure.

proc means data=JH.Final3;
var csrpa_mlm2; 
output out=out mean=mean std=sd;
run;
data mdat;
set out;
keep csrpa_mlm2;
do csrpa_mlm2 = mean-sd, mean, mean+sd;
output;
end;
run;
%Margins(data=JH.Final3, response=Norepinephrine, model=cage ClinicSex marriedmidus work race_orig  cedu cHHtotalIncome EverSmokeReg Exercise20mins CNSmeds cBMI cCESD cNeuroticism  cChronCondNumb  cAnyStressWide_sum cpa_mlm2 csrpa_mlm2,
margins=csrpa_mlm2, margindata=mdat,
options=diff reverse cl)

proc sort data=_margins; 
by csrpa_mlm2;
run;

proc sgplot data=_margins noautolegend;
band upper=UPPER lower=LOWER x=csrpa_mlm2 ;*/ transparency=.3;
series y=ESTIMATE x=csrpa_mlm2;
xaxis values=(-0.0627096 0 0.0627096) grid offsetmin=.05 offsetmax=.05
label="Positive Affective Responsivity";
yaxis values=(10 to 40  by 5) grid offsetmin=.05 offsetmax=.05 
label="Norepinephrine";
title "Effects of Positive Affective Responsivity on Norepinephrine";
run;

 

 

 

Heejeong_0-1653930640823.png

 

As you can see the "Negative Affective Responsivity" is currently graphed at -1SD (which is -0.11 in the figure), Mean (which is 0 in the figure), and +1SD (which is 0.11 in the figure). I want to graph it so that Negative Affective Responsivity is graphed by percentage so that the interpretation could be that with X% increase of Negative Affective Responsivity, we see XX increase in levels of norepinephrine.

 

If there is anything else that's confusing, please let me know and I really appreciate your help!

 

 

 

Rick_SAS
SAS Super FREQ

The code and the graph do not agree. The graph is for "Negative Affective Responsivity" whereas the code creates a graph for "Positive Affective Responsivity".  Furthermore, I cannot use your data because it contains user-defined formats that I do not have:

ERROR: The format B1PAGE_F was not found or could not be loaded.
ERROR: The format B1PRSEXF was not found or could not be loaded.
ERROR: The format B1PA7CFF was not found or could not be loaded.

...

 

Regardless, the question is "percentage of WHAT?" Of the total range of the csrpa_mlm2 variable? If so, compute the MIN and MAX of csrpa_mlm2 in the initial PROC MEANS step, then create new values at the mean +/- 1% of the range. For example:

proc means data=JH.Final3;
  var csrpa_mlm2; 
  output out=out mean=mean std=sd min=Min max=Max;
run;

data mdat;
set out;
keep csrpa_mlm2;
P1 = 0.01 / (Max - Min);
do csrpa_mlm2 = mean-P1, mean, mean+P1;
   if csrpa_mlm2 = mean-P1 then csrpa_mlm2_Pct = -0.01;
   else if csrpa_mlm2 = mean+P1 then csrpa_mlm2_Pct = 0.01;
   else csrpa_mlm2_Pct = 0.0;
   output;
end;
format csrpa_mlm2_Pct PERCENT6.2;
run;

Notice that instead of evaluating the model at 

do csrpa_mlm2 = mean-sd, mean, mean+sd

this code evaluates the model at

do csrpa_mlm2 = mean-P1, mean, mean+P1

Since the model is linear, it shouldn't matter where you evaluate the model.

 

To display percentages on the plot, use the csrpa_mlm2_Pct as the X= variable.

 

 

This is untested, but hopefully it will be helpful.

 

 

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
  • 3 replies
  • 637 views
  • 0 likes
  • 2 in conversation