BookmarkSubscribeRSS Feed
Jaime
Fluorite | Level 6
I am using the below code to drisplay 3 charts for the level variable.
The procedure sorts the levels alphabetically. I want to force another order. Is there a way to do this?


proc sgpanel data=to_plot;
panelby level/columns=1;
vbar time/response=ratio datalabel ;
format ratio percent.;
run;
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest doing a Google advanced search against the SAS.COM support website - here is one that works quite well for this post:

sgpanel panelby sort order site:sas.com

Scott Barry
SBBWorks, Inc.
Jaime
Fluorite | Level 6
Scott,

Thanks for your “Google it” suggestion. However, I was unable to find the answer I was looking for. Maybe I’m missing something.
I am trying to use proc format to order the panel outcome of the sgpanel. Similar to how you would use it to order a variable in proc report using a specific order. It’s not alphabetical nor numerical.

Cheers.
GraphGuy
Meteorite | Level 14
If you're comfortable with user-defined formats, you could assign numeric values to the "level", which would be used to control the order of the charts, and then have the user-defined format print those numeric values as the desired text (the charts will be ordered by the pre-formatted numeric values).

Here is a variations of your code that demonstrates this:

proc format;
value my_fmt
1 = "ZZZ"
2 = "MMM"
3 = "AAA"
;
run;

data to_plot;
format level my_fmt.;
input level time ratio;
datalines;
1 1 .2
1 2 .25
1 3 .33
2 1 .6
2 2 .55
2 3 .67
3 1 .11
3 2 .22
3 3 .25
;
run;

proc sgpanel data=to_plot;
panelby level/columns=1;
vbar time/response=ratio datalabel ;
format ratio percent.;
run;



And, if you're really comfortable with user-defined formats, you can even create the format in a data-driven manner, using a "cntlin" data set.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 1836 views
  • 0 likes
  • 3 in conversation