i am using the following code
proc sgpanel data=dataset noautolegend;
format ....;
panelby cohort / onepanel spacing=2 headerattrs=(size=14) novarname;
vline timevar / response=var stat=mean limits=both markers group=grps;
rowaxis label="my variable" labelattrs=(size=16) valueattrs=(size=14) ;
colaxis label="time" labelattrs=(size=16) valueattrs=(size=14) ;
run;
quit;
but i want to plot box plots over time, not the mean and CI which this is producing. I can't see any way to do this using sgpanel. I could do something like "vbox var / category=timevar" but then i lose grps (each panel should have 2 series of box plots over time, one for each group, and time is discrete/categorical)
cheers!
The vbox statement in sgpanel does support the group= option, at least in version 9.4M5
@pau13rown wrote:
i am using the following code
proc sgpanel data=dataset noautolegend;
format ....;
panelby cohort / onepanel spacing=2 headerattrs=(size=14) novarname;
vline timevar / response=var stat=mean limits=both markers group=grps;
rowaxis label="my variable" labelattrs=(size=16) valueattrs=(size=14) ;
colaxis label="time" labelattrs=(size=16) valueattrs=(size=14) ;
run;
quit;
but i want to plot box plots over time, not the mean and CI which this is producing. I can't see any way to do this using sgpanel. I could do something like "vbox var / category=timevar" but then i lose grps (each panel should have 2 series of box plots over time, one for each group, and time is discrete/categorical)
cheers!
Why is there no VBOX or HBOX if you want box plots? If you want separate box plots at each "time" then add that variable to your panelby statement though sometimes getting the row and column settings to match what you intend is tricky.
If you are attempting to combine a Vline and a box then you will need to move over to Graphics Template language as HBOX and VBOX cannot be combined with other plot statements in SGPanel (at least not in my SAS 9.4 according to the documentation)
The VBOX statement cannot be used together with other plot statements in the SGPANEL procedure. Box plots can be overlaid with other box plots. However, overlaid box plots must have the same category variables.
A minimal example data set with (dummy values for your variables if sensitive) to create a few cohort/time combinations would help provide a more complete example.
adding time to panelby would just generate a whole bunch more panels, one for each timepoint. Imagine a single figure within a single panel. In that figure i want timepoint on the x axis. There is no vbox in my code because it wouldn't produce what i need, that's the problem. My suspicion is that i need to use sgplot and greplay, but i hope not because that would be a hassle. I appreciate that's it's maybe not easy to visualise, i'd provide an example of what i need but nothing appears in a google search, that's why im asking here....
The vbox statement in sgpanel does support the group= option, at least in version 9.4M5
excellent, youre right, it worked! it doesn't appear in the help page so i thought it wasnt an option: http://support.sas.com/documentation/cdl/en/grstatproc/62603/HTML/default/viewer.htm#panelvbox-stmt....
Check out the version number. That's the help page for version 9.2, it's 10 years old!
i need to bookmark the current sas help weblink 🙂
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.