BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
OS2Rules
Obsidian | Level 7

Hi All:

Is it possible to use regression when creating the GBARLINE PLOT?

I have a symbol statement but it seems to ignore this.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

The fundamental problem with doing regression lines in bar charts (and therefore bar-line charts)

is that the bars are considered to be evenly-spaced (character) variables, rather than treated

as a proportionally-spaced numeric axis.

To plot a regression line, you'd want to use a Gplot with a numeric axis.  You can then 'fake'

the bars in the Gplot by using the 'needle' interpolation.

Here is a GBarline example I've modified to use Gplot, and do a regression line:

title1 "NYSE Closing Price and Volume - 2002";
  data nyse;
   format Day date7.;
   format High Low Close comma12.;
   format Volume comma12.;
   input Day date7. High Low Close Volume;
datalines;
01AUG07 10478.76 10346.24 10426.91 1908809
02AUG07 11042.92 10298.44 10274.65 1807543
05AUG07 10498.22 10400.31 10456.43 1500656
06AUG07 10694.47 10636.32 10762.98 1498403
07AUG07 10801.12 10695.13 10759.48 1695602
run;

symbol1 value=none interpol=needle width=15 color=blue;
symbol2 value=dot interpol=rl color=black;


axis1 offset=(15,15);

proc gplot data=nyse;
plot volume*day=1 / haxis=axis1;
plot2 close*day=2 / haxis=axis1;
run;

View solution in original post

2 REPLIES 2
GraphGuy
Meteorite | Level 14

The fundamental problem with doing regression lines in bar charts (and therefore bar-line charts)

is that the bars are considered to be evenly-spaced (character) variables, rather than treated

as a proportionally-spaced numeric axis.

To plot a regression line, you'd want to use a Gplot with a numeric axis.  You can then 'fake'

the bars in the Gplot by using the 'needle' interpolation.

Here is a GBarline example I've modified to use Gplot, and do a regression line:

title1 "NYSE Closing Price and Volume - 2002";
  data nyse;
   format Day date7.;
   format High Low Close comma12.;
   format Volume comma12.;
   input Day date7. High Low Close Volume;
datalines;
01AUG07 10478.76 10346.24 10426.91 1908809
02AUG07 11042.92 10298.44 10274.65 1807543
05AUG07 10498.22 10400.31 10456.43 1500656
06AUG07 10694.47 10636.32 10762.98 1498403
07AUG07 10801.12 10695.13 10759.48 1695602
run;

symbol1 value=none interpol=needle width=15 color=blue;
symbol2 value=dot interpol=rl color=black;


axis1 offset=(15,15);

proc gplot data=nyse;
plot volume*day=1 / haxis=axis1;
plot2 close*day=2 / haxis=axis1;
run;

OS2Rules
Obsidian | Level 7

Robert:

That is exactly what I wound up doing.  I was just hoping that htere was some way for the GBARLINE to honour the SYMBOL statement and use the I=RL.

I found out (after a quick call to tech support) that the GBARLINE will only use I=JOIN, no matter what you code.

I would rather use a VBAR chart and overlay the regression line with ANNOTATE, but we don't have SAS STAT here and my statistics are rather rusty.

Thanks again.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 730 views
  • 0 likes
  • 2 in conversation