BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nasser_DRMCP
Lapis Lazuli | Level 10

Hello,

I use proc sgplot . the group is the column "Profil" with 4 values NA, P1, P2 and P3.

the values of xaxis are N, N+1, N+2, N+3...(years)

The problem is the following : I would like that xaxis values are sorted like N, N+1, N+2...N+8. but as you can notice in the enclosed picture , they are not sorted because the profiles P1 P2 and P3 have the x values N, N+1, N+2 But the NA profil has x values N+5 to N+8.

profile.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Create another variable that maps N to 0, N+1 to 1, N+2 to 2, etc. 

Then use that variable as your X axis, but create a format that displays it as N, N+1. 

 

 

View solution in original post

6 REPLIES 6
Reeza
Super User

Create another variable that maps N to 0, N+1 to 1, N+2 to 2, etc. 

Then use that variable as your X axis, but create a format that displays it as N, N+1. 

 

 

Nasser_DRMCP
Lapis Lazuli | Level 10

thank you very much Reeza for you quick answer.

I create the new variable but only 0 2 4 6 8 are displayed. 1 3 5 7 are missing on the x axis

Nasser_DRMCP
Lapis Lazuli | Level 10

I succed to get the correct values in x axis by using min max values in variable and then I can do this :

xaxis display = (nolabel) discreteorder = FORMATTED values=(&v_min_xaxis. to &v_max_xaxis. by 1) ;

Nasser_DRMCP
Lapis Lazuli | Level 10

Hello Reeza

 

I don't succeed to create a format that displays (0,1,2,3...)  as N, N+1, N+2... 

Thanks a lot in advance for your help

Nasser

Nasser_DRMCP
Lapis Lazuli | Level 10

I succeeded to create the format like this

proc format ; picture Format_Year_Suite low-high = '00' (prefix='N + ') ; run;

 

and then within the proc sgplot I mentionne

format Suite_Year_4_Sort Format_Year_Suite. ;

 

the problem is that it works for all numbers except 0 which is not displays.

 

ballardw
Super User

Perhaps something like:

proc format library=work; 
picture Format_Year_Suite 
0      = 'N' (noedit)
0<-high = '09' (prefix='N + ') ; 
run;

data _null_;
do x= 0 to 10;
put x= best5. +1 x= format_year_suite.;
end;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 1745 views
  • 3 likes
  • 3 in conversation