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

Hi, I'm trying to to a VBOX PLOT. 

I have a data set like: I have 24 intervals, I1-I24

_LABEL_  COL1

I1             0

I1             4

I10           7

I10           7

I11          6

I11          5

....

I8            4

I8            6

I9            4

I9            5

I has to sort it to transpose my data. 

When I run:

 

 proc sgplot data=mergedt;
vbox COL1/ category=_LABEL_;
xaxis grid label="Interval" discreteorder=data;
yaxis grid label="XX";
run;

My plot in xaxis is I1 I10 I11 I12 .. I19 I2 20 I21 .. I24 I3 I4 ..I9

I need my xaxis like I1 I2 I3 I4 ..... I23 I24

 

I have try with discreteorder=format or unformart and it is the same result. Any idea to "unsort it" or have the xaxis in numeric order?

 

Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

The typical solution is a custom format. Map each Label to a numeric variable that sorts correctly and then a format that maps to the variable you want displayed. 

 

Proc format;

value Icat

1= 'I1'

2='I2'

...

24='I24';

 

proc SGPLOT ...;

....

format label icat.;

run;quit;

View solution in original post

2 REPLIES 2
Reeza
Super User

The typical solution is a custom format. Map each Label to a numeric variable that sorts correctly and then a format that maps to the variable you want displayed. 

 

Proc format;

value Icat

1= 'I1'

2='I2'

...

24='I24';

 

proc SGPLOT ...;

....

format label icat.;

run;quit;

ballardw
Super User

Or use Proc Sort to sort the data with the SORTSEQ option Linguistic with Numeric_Collation=On

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