Suppose I have a data set with class variable with 4 levels: A, B, C and D. If I want to creater four series plots in SAS Studio I can run the following code using proc sgpanel
.
proc sgpanel data = name;
panelby class;
series X = var1 Y = var2 / group = some_factor;
run;
How can modify this code to instead create 2 panels where the first panel has the graphs of both A and B and the second C and D? A naive solution would be to add a "dummy" 0-1 variable to the data set and using panelby dummy
. However I was hoping for a more elegant solution!
Edit: To clarify I want to have different graphs for A and B in the same panel, not combine data into one graph.
If you're aiming to combine the A/B and C/D into one series each, then this is straightforward.
Using this
sashelp.class
example as the base:We create a format that combines the class values in whatever fashion is preferred:
Then apply the format.
This won't show separate plots for the individual class values on the panel; if that's desired, then
group
could be used with a second class variable (an identical, but second, variable). However, ifgroup
is already being used, as in the updated question, it might be complicated to implement this. Separateseries
statements could be used to show each, but this is perhaps additionally complex.Here's one way to do the overlaid groups - just copying
age
toage2
.I think that in GTL you might be able to do it without actually creating a second variable, but I don't think it's possible in regular SGPanel.