BookmarkSubscribeRSS Feed
jglew
Fluorite | Level 6

I am running the following code to create several horizontal bar charts:

 

proc sgpanel data=mydata;

panelby by panelvar;

hbarparm category=catvar response=size;

run;

 

The problem I run into is that each of my panelvar values has differet catvar values. SGPANEL produces horizontal bar charts with bars for every category in the data set in each panel. In each panel, I really just want to see bars for categories that exists for that panelvar value.

 

Is there a way to do this with PROC SGPANEL or do I have to use PROC SGPLOT with a BY statement?

5 REPLIES 5
PGStats
Opal | Level 21

Try option UNISCALE=ROW in the PANELBY statement.

PG
jglew
Fluorite | Level 6

Unfortunately, that doesn't do quite what I'm looking for. Here is a code example that uses sashelp.cars:

 

proc sgpanel data=sashelp.cars (where=(Make like 'A%'));

panelby make / columns=1 uniscale=row;

hbarparm category=model response=MPG_City;

run;

 

I'd like to make it so only the models for Audi show up in the Audi panel, only the models for Acura in the Acura panel, etc.

PGStats
Opal | Level 21

Smiley Frustrated I always mix those up! You need  UNISCALE=COLUMN !

PG
jglew
Fluorite | Level 6

Great! That worked. Thanks so much.

Jay54
Meteorite | Level 14

With SAS 9.4, you can use the PROPORTIONAL option to make all bars the same thickness regardless of the number in each cell.

 

proc sgpanel data=sashelp.cars (where=(Make like 'A%'));
  panelby make / columns=1 uniscale=column proportional;
  hbarparm category=model response=MPG_City;
run;

 

CarsPanel.png

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1648 views
  • 1 like
  • 3 in conversation