Data visualization with SAS programming

Does sgscatter have the ability to show multiple lines on one graph?

Reply
Super Contributor
Posts: 494

Does sgscatter have the ability to show multiple lines on one graph?

Does SG scatter have the ability to show multiple lines on one graph.  E.g.

proc sgscatter  data=temp;

plot (weight height)*age / join;

run;

Displays a graph with weight and age and a graph with height and age.

proc sgscatter  data=temp;

plot ((weight of molly john matt sam) (height of molly sam matt)*age / join;

run;

I’m trying to obtain the group functionality of sgplot but the shared legend of sgscatter.

SAS Super FREQ
Posts: 925

Re: Does sgscatter have the ability to show multiple lines on one graph?

You can use a GROUP to do this:

proc sgscatter  data=temp;

plot (weight height)*age / join group=sex;

run;

Super Contributor
Posts: 494

Re: Does sgscatter have the ability to show multiple lines on one graph?

Does sgscatter have a stat feature like the stat feature of sgplot where you can compare roll the data up by summation e.g.

stat=sum

SAS Super FREQ
Posts: 925

Re: Does sgscatter have the ability to show multiple lines on one graph?

No, you need to use PROC MEANS or PROC SUMMARY to do the data summarization before you plot it.

Super Contributor
Posts: 494

Re: Does sgscatter have the ability to show multiple lines on one graph?

By using a summary method I was able to see my data in groups of lines.

Does sgscatter have a panel by feature like sgpanel?

  1. E.g. if car is blue show in panel one, if car is red show in panel two

I’m researching the join and compare features and these seem to be designed to show different variables on each graph rather than a split of a group.

SAS Super FREQ
Posts: 925

Re: Does sgscatter have the ability to show multiple lines on one graph?

If you want a graph of that form, is is best to use SGPANEL:

proc sgpanel data=raw_data;

panelby color;

vline c / response= r group=g stat=sum markers;

run;

-- or --

proc sgpanel data=sum_data;

panelby color;

series x=x y=y / group=g markers;

run;

Super Contributor
Posts: 494

Re: Does sgscatter have the ability to show multiple lines on one graph?

The problem with using sgpanel is that I need to resize the series scale.  I looked at the option of using uniscale=row layout=columnlattice.  However  I need to conserve space.  Sgpannel is great for placing two line graphs side by side if they have the same scale. It can nicely place them one one top of the other with different scales.  If you place the graphs side by side ( which  I need to do ) and use sgpanel the line goes vertical in a way in which the reader will have extreme difficultly reading the graph.  I found sgpanel useful for side by side barcharts with different scales.

Which is why I am looking into ways to use sgscatter. The ideal output would be

Line Graph 1 with series 1 line graph 2 with series 2.

Super Contributor
Posts: 494

Re: Does sgscatter have the ability to show multiple lines on one graph?

I ended up hard coding a separate legend for this beside my graphs.

Ask a Question
Discussion stats
  • 7 replies
  • 723 views
  • 1 like
  • 2 in conversation