BookmarkSubscribeRSS Feed
TMAlves
Calcite | Level 5

Hi there,

I have the following script to plot regression models, but there are four main problems that I could not figure out using the available manuals:

1)    Remove minor ticks in both axis.

2)    Include the linear regression model inside the graph using three decimal cases and rename the variables, i.e., Y = a – bx (R2 = 0.003).

3)    Graph frame should be thicker.

4)    Size of the number of both axis should size 12pt.

I included the current output and the desired graph to ilustrate what I need.

Thank you so much for considering helping.

current_graph.jpg.desired_graph.jpg

LEGEND1 value=(f=times h=12pt)

POSITION= (bottom center inside)

MODE=protect

noframe;

AXIS1 major =(h=1)

order=(0 to 3600 by 400)

LABEL=(ANGLE=360 ROTATE=0 HEIGHT=14pt font=times 'Cumulative aphid-days');

SYMBOL1 pointlabel = ("#Plot" h=2 font=times h=10pt color=black)  value=none I=RL;

AXIS2 major =(h=1)

order=(0 to 1 by 0.2)

LABEL=(ANGLE=90 ROTATE=0 HEIGHT=14pt font=times 'NDVI');

SYMBOL2 color=black font=times;

PROC SORT DATA=ALLOPENP; BY DateA Place; RUN;

proc gplot data=ALLOPENP; BY DateA Place;

plot NDVI*CUMADAYTaphid/

haxis =axis1 

vaxis =axis2

caxis=black

regeqn

legend=legend1;

run;quit;

4 REPLIES 4
GraphGuy
Meteorite | Level 14

1)    Remove minor ticks in both axis.

axis2 minor=none;

2)    Include the linear regression model inside the graph using three decimal cases and rename the variables, i.e., Y = a – bx (R2 = 0.003).

You'll probably have to calculate the values, and then stuff them into a custom text string, and annotate it onto the graph.

3)    Graph frame should be thicker.

axis2 width=2

4)    Size of the number of both axis should size 12pt.

axis2 value=(height=12pt)

TMAlves
Calcite | Level 5

Thank you Robert.

Considering your suggestion for question (2), I calculated the values and called them in a macro variable.

However, I have a BY statement and the macro variable saved only the last intercept and slope.

Any idea how to save the values for each DATE and PLACE? I am thinking to use each value in a custom text string onto the graph.

PROC REG DATA=ALLOPENP; BY DateA Place;

MODEL NDVI=CUMADAYTaphid;

ODS OUTPUT ParameterEstimates=estimates FitStatistics=stats;

run;

DATA reg_results; MERGE estimates stats; BY DateA Place;

    if variable="CUMADAYTaphid" then call symput("slope", estimate);

    if variable="Intercept" then call symput("intercept", estimate);

    if Label2="R-Square" then call symput("rsquare", cValue2);

run;

Reeza
Super User

You need to add in an N to your slope, so that you have multiple slope macro variables, ie

slope1 slope2 ... slopeN

DATA reg_results; MERGE estimates stats; BY DateA Place;

    if variable="CUMADAYTaphid" then call symput("slope"||put(_n_,2. -l), estimate);

    if variable="Intercept" then call symput("intercept"||put(_n_,2. -l), estimate);

    if Label2="R-Square" then call symput("rsquare"||put(_n_,2. -l), cValue2);

run;

KenDodds
Calcite | Level 5

For putting a regression equation on each graph, have a look at the ANNOTATE facility. You can use that with BY group processing, so once you have figured out how to use it for one graph (takes a bit of work) it should be straight foward getting what you want for all the graphs.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1968 views
  • 3 likes
  • 4 in conversation