Hi, I am trying to make a graph as depicted below (i.e. I am trying to split my red bars into two groups, blue bars into two groups, and green bars into two groups). I would use SGPANEL, but I have custom CI's which I'd like to insert. I am using SAS v9.4.
Can't see the problem with sgpanel...
proc sql;
create table heartBars as
select
sex,
smoking_status,
round(ageAtStart,10) as ageClass,
mean(Cholesterol) as meanCh,
mean(Cholesterol) + std(Cholesterol) as topCh,
mean(Cholesterol) - std(Cholesterol) as lowCh
from sashelp.heart
group by sex, smoking_status, calculated ageClass;
quit;
proc sgpanel data=heartBars;
panelBy sex;
vbarparm category=ageClass response=meanCh / groupdisplay=cluster
group=smoking_status limitlower=lowCh limitupper=topCh;
run;
Can't see the problem with sgpanel...
proc sql;
create table heartBars as
select
sex,
smoking_status,
round(ageAtStart,10) as ageClass,
mean(Cholesterol) as meanCh,
mean(Cholesterol) + std(Cholesterol) as topCh,
mean(Cholesterol) - std(Cholesterol) as lowCh
from sashelp.heart
group by sex, smoking_status, calculated ageClass;
quit;
proc sgpanel data=heartBars;
panelBy sex;
vbarparm category=ageClass response=meanCh / groupdisplay=cluster
group=smoking_status limitlower=lowCh limitupper=topCh;
run;
Thanks!
Just for completeness, here's how you can get limits within SGPANEL without external calculations:
proc sgpanel data=sashelp.heart (where=(ageatstart >= 50 and ageatstart < 53));
panelBy sex;
vbar ageatstart / response=cholesterol groupdisplay=cluster
group=smoking_status stat=mean limitstat=stddev;
run;
When I try to replicate this in v9.4 with the same code:
proc sgpanel data=murdock.test;
panelBy sex;
vbarparm category=age_group response=meanNP / group=wave groupdisplay=cluster
limitlower=lowNP limitupper=topNP;
run;
receive this error msg:
71 proc sgpanel data=murdock.test;
72 panelBy sex;
73 vbarparm category=age_group response=meanNP / group=wave groupdisplay=cluster
------------
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, ATTRID, BARWIDTH, CLUSTERWIDTH, DATALABEL, DATALABELATTRS,
DATASKIN, DISCRETEOFFSET, FILL, FILLATTRS, GROUP, GROUPORDER, LEGENDLABEL, LIMITATTRS, LIMITLOWER, LIMITUPPER,
MISSING, NAME, NOFILL, NOOUTLINE, OUTLINE, TRANSPARENCY, URL.
ERROR 76-322: Syntax error, statement will be ignored.
74 limitlower=lowNP limitupper=topNP;
75 run;
71 proc sgpanel data=murdock.test;
72 panelBy sex;
73 vbarparm category=age_group response=meanNP / group=wave groupdisplay=cluster
------------
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, ATTRID, BARWIDTH, CLUSTERWIDTH, DATALABEL, DATALABELATTRS,
DATASKIN, DISCRETEOFFSET, FILL, FILLATTRS, GROUP, GROUPORDER, LEGENDLABEL, LIMITATTRS, LIMITLOWER, LIMITUPPER,
MISSING, NAME, NOFILL, NOOUTLINE, OUTLINE, TRANSPARENCY, URL.
ERROR 76-322: Syntax error, statement will be ignored.
74 limitlower=lowNP limitupper=topNP;
75 run;
If I try PROC SGPANEL w/ VBAR, the excellent bar graph appears, but without error bars.
proc sgpanel data=murdock.pals_v1_v2_phys_perf;
panelBy sex;
title1 font="helvetica/bold"
'PALS Usual Gait Speed (Age Group by Visit by Sex)';
vbar age_group / response=normal_pace groupdisplay=cluster dataskin=matte
group=wave stat=mean limitstat=stddev;
run;
Thanks,
Andy
The early versions of VBARPARM/HBARPARM did not have the GROUPDISPLAY option; however, the default was a CLUSTER appearance. Just take the option away and it should work for you.
As for SGPANEL not producing the error bars, was there a message in the log?
Thanks!
Dan
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.