BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
richart
Fluorite | Level 6

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. 

graph.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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;

SGPanel1.png

PG

View solution in original post

6 REPLIES 6
PGStats
Opal | Level 21

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;

SGPanel1.png

PG
richart
Fluorite | Level 6

Thanks!

DanH_sas
SAS Super FREQ

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;

 

A_Shiloh
Calcite | Level 5

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

DanH_sas
SAS Super FREQ

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

A_Shiloh
Calcite | Level 5
1) Yes, Removing GROUPDISPLAY solved the problem.

There was a WARNING in the log re: the GROUP option:
WARNING: Limits are not allowed on bar charts when a group variable is used. The option will be ignored.

I am fine w/ calculating the MEAN and STDDEV for the variables and using VBARPARM.

Thanks for your help!

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 8944 views
  • 0 likes
  • 4 in conversation