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

Hello all,

 

I have a three dimensional data (year, source and mechanism) as in the example below and trying to display it via PROC SGPANEL but the code below stacks the source dimension on top of each other as opposed to what I want which is side by side. Lastly, I also would like to be able to show the labels for each three dimensions but could show only two (year and source). I was wondering if anyone can help?

 

Thanks a lot in advance!

 

Recep

 

PS: I'm not trying to create a 3-dimensional figure. Just trying to show my three-dimensional data in a usual 2-dimensional barchart by putting bars next to each other.

 

DATA cars1;
length Mechanism $10. Year $9.;
INPUT source $ Mechanism $ Year $ Count;
CARDS;
BCTR Scooter 2016/2017 17
BCTR Scooter 2017/2018 13
BCTR Scooter 2018/2019 17
BCTR Car 2016/2017 119
BCTR Car 2017/2018 133
BCTR Car 2018/2019 118
BCTR Motorcycle 2016/2017 47
BCTR Motorcycle 2017/2018 62
BCTR Motorcycle 2018/2019 63
BCTR Bicycle 2016/2017 82
BCTR Bicycle 2017/2018 90
BCTR Bicycle 2018/2019 85
BCTR Pedestrian 2016/2017 72
BCTR Pedestrian 2017/2018 82
BCTR Pedestrian 2018/2019 83
DAD Scooter 2016/2017 26
DAD Scooter 2017/2018 21
DAD Scooter 2018/2019 20
DAD Car 2016/2017 264
DAD Car 2017/2018 292
DAD Car 2018/2019 262
DAD Motorcycle 2016/2017 105
DAD Motorcycle 2017/2018 115
DAD Motorcycle 2018/2019 117
DAD Bicycle 2016/2017 314
DAD Bicycle 2017/2018 293
DAD Bicycle 2018/2019 321
DAD Pedestrian 2016/2017 176
DAD Pedestrian 2017/2018 154
DAD Pedestrian 2018/2019 150

;
RUN;


proc sgpanel data=cars1;
panelby year /layout=columnlattice
onepanel
colheaderpos=bottom
rows=1
novarname
noborder;
vbar mechanism /group=source
response=count;
colaxis display=none;
rowaxis grid;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Is this what you are looking for:

 

proc sgpanel data=cars1;
panelby year /layout=columnlattice
onepanel
colheaderpos=bottom
rows=1
novarname
noborder;
vbar mechanism /group=source groupdisplay=cluster
response=count;
colaxis display=none;
rowaxis grid;
run;

I am not quite sure what you mean by "labels each of three dimensions". Can you describe what variable has the value you want and where it should appear?

View solution in original post

2 REPLIES 2
ballardw
Super User

Is this what you are looking for:

 

proc sgpanel data=cars1;
panelby year /layout=columnlattice
onepanel
colheaderpos=bottom
rows=1
novarname
noborder;
vbar mechanism /group=source groupdisplay=cluster
response=count;
colaxis display=none;
rowaxis grid;
run;

I am not quite sure what you mean by "labels each of three dimensions". Can you describe what variable has the value you want and where it should appear?

Recep
Quartz | Level 8
Thanks a lot! I was so stuck on including an additional VBAR or GROUP= statement that I did not even think about GROUPDISPLAY! Really appreciate your help!!!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 468 views
  • 0 likes
  • 2 in conversation