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

I am trying to change my x axis ticks, but every time I do it either lumps the data into the new ticks or drops all data on years with no tick instead of just changing the labels. 

What is the correct way to change axis ticks without combining or losing my data?

 

This is what I have:

filename test1234 url "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-09-21/nominees.csv";

proc import out=nominees datafile=test1234 dbms=csv replace; 
	guessingrows = max; 
run;

proc sgplot data=nominees;
	where year > 1000;
	vbar year / group = type stat=freq groupdisplay=stack;
	xaxis label = "Year"  values=(1960 to 2020 by 5);
run;

Indescribled_1-1632369787221.png

This is what I want the x axis and plot layout to look like (image from R, but I cannot do it in SAS to show is the issue):

Indescribled_0-1632369425047.png

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Please try to use the option type=linear in xaxis statement as below 

 

proc sgplot data=nominees;
	where year > 1000;
	vbar year / group = type stat=freq groupdisplay=stack grouporder=descending;
	xaxis label = "Year"  type=linear values=(1960 to 2020 by 5);
run;

 

Jagadishkatam_0-1632382688939.png

 

 

 

 

 

Thanks,
Jag

View solution in original post

1 REPLY 1
Jagadishkatam
Amethyst | Level 16

Please try to use the option type=linear in xaxis statement as below 

 

proc sgplot data=nominees;
	where year > 1000;
	vbar year / group = type stat=freq groupdisplay=stack grouporder=descending;
	xaxis label = "Year"  type=linear values=(1960 to 2020 by 5);
run;

 

Jagadishkatam_0-1632382688939.png

 

 

 

 

 

Thanks,
Jag

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 317 views
  • 3 likes
  • 2 in conversation