BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Junyong
Quartz | Level 8

SGPLOT VBAR is drawing all the 50 bars needed, but can I just apply label intervals to the x-axis below so that it changes from 1, 2, 3, …, 48, 49, 50 to 5, 10, 15, …, 40, 45, 50, for example?

data SAMPLE;
    call streaminit(1);
    do X=1 to 50;
        do ITERATION=1 to 50;
            Y=rand('normal',X,X);
            output;
        end;
    end;
run;

ods results=off;
ods listing gpath='!userprofile\desktop\';
ods graphics/reset imagename='SGPLOT';

proc sgplot;
    vbar X/response=Y stat=mean limits=both;
run;

SGPLOT.png

Thanks for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @Junyong,

 

First of all, thank you very much for providing readily usable example data and code.

 

I think adding this XAXIS statement to your PROC SGPLOT step will help:

xaxis values=(5 to 50 by 5) type=linear valueshint;

The default axis type in your case would be DISCRETE, not LINEAR, so that the VALUES= specification alone would also restrict the set of bars drawn. Without the VALUESHINT option SAS would not leave enough space for the bars with X values less than the first tick mark value (5).

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hello @Junyong,

 

First of all, thank you very much for providing readily usable example data and code.

 

I think adding this XAXIS statement to your PROC SGPLOT step will help:

xaxis values=(5 to 50 by 5) type=linear valueshint;

The default axis type in your case would be DISCRETE, not LINEAR, so that the VALUES= specification alone would also restrict the set of bars drawn. Without the VALUESHINT option SAS would not leave enough space for the bars with X values less than the first tick mark value (5).

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 302 views
  • 0 likes
  • 2 in conversation