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.
You can use a GROUP to do this:
proc sgscatter data=temp;
plot (weight height)*age / join group=sex;
run;
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
No, you need to use PROC MEANS or PROC SUMMARY to do the data summarization before you plot it.
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?
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.
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;
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.
I ended up hard coding a separate legend for this beside my graphs.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.