Data visualization with SAS programming

SGPANEL order

Reply
Frequent Contributor
Posts: 115

SGPANEL order

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;
Super Contributor
Super Contributor
Posts: 3,174

Re: SGPANEL order

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.
Frequent Contributor
Posts: 115

Re: SGPANEL order

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.
SAS Employee
Posts: 963

Re: SGPANEL order

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.
Post a Question
Discussion Stats
  • 3 replies
  • 196 views
  • 0 likes
  • 3 in conversation