BookmarkSubscribeRSS Feed
Zatere
Quartz | Level 8

Hello,

 

I am trying to create different charts. One of them is a bar chart with line using the following code:

 

data have;
input Date date9. Sales	Quantity;
format Date date9.;
datalines;
01JUN2021 364006287 86545
01JUL2021 351441743 126849
01AUG2021 365035146 203439
01SEP2021 383481270 215328
01OCT2021 345389961 264014
01NOV2021 359418744 275509
01DEC2021 337830282 185482
01JAN2022 315745823 198505
01FEB2022 300595859 133222
01MAR2022 358007728 128706
01APR2022 335333224 163816
01MAY2022 365721095 198218
01JUN2022 352080100 298018
;
run;

proc gbarline data=have;
  vbar date / sumvar=sales discrete levels=all;
  plot      / sumvar=Quantity
 ;
run;

 

That gives the below warning: 

WARNING: The intervals on the axis labeled "Date" are not evenly spaced.

Any ideas how I could fix this please?

 

As it can be seen below, I am looking for something similar even using different PROC:

 

Capture.JPG

Thanks.

2 REPLIES 2
ballardw
Super User

Fix what? The warning or the graph?

 

Months have different lengths. So to make a uniform boundary/width you are going to spend time to get ticks and widths that are uniform and the labels to make sense with those modified xaxis values to suppress the warning.

 

This is one of those warnings that when you are using dates you basically can ignore but is there to remind you just in case you don't remember.

You can suppress warnings using system options for bits of code, turn off then turn on after if you are sure the only warning you will ever receive is this one.

Ksharp
Super User
data have;
input Date date9. Sales Quantity;
format Date date9.;
datalines;
01JUN2021 364006287 86545
01JUL2021 351441743 126849
01AUG2021 365035146 203439
01SEP2021 383481270 215328
01OCT2021 345389961 264014
01NOV2021 359418744 275509
01DEC2021 337830282 185482
01JAN2022 315745823 198505
01FEB2022 300595859 133222
01MAR2022 358007728 128706
01APR2022 335333224 163816
01MAY2022 365721095 198218
01JUN2022 352080100 298018
;
run;

proc sgplot data=have noautolegend;
vbarparm category=Date response=Sales / fillattrs=graphdata1;
series x=Date y=Quantity /markers lineattrs=graphdata2 y2axis markerattrs=graphdata2(symbol=circlefilled);

yaxis labelpos=top valuesformat=best32. labelattrs=graphdata1 valueattrs=graphdata1;
y2axis labelpos=top valuesformat=best32. labelattrs=graphdata2 valueattrs=graphdata2;
xaxis  fitpolicy=stagger;
run;

Ksharp_0-1658406391196.png

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 673 views
  • 2 likes
  • 3 in conversation