BookmarkSubscribeRSS Feed
Calcite | Level 5

Hi teams, I am  trying to set the x-axis on my chart to show only the date per seven days. However I want to keep the x-axis data shown on my chart to represent each day in my data set, which represents about 42 days (similar to the attached example).  The main purpose is to not clutter the x-axis.  I am not sure what function I need to have. Below is my script where I uses proc sgplot. I have also tried using proc gchart.


The source dataset is  simple, witht 84 rows and three columns  - Activity Date (Act_Date),  Receipt_Count (integer), and Receipt_Code (string)


proc sgplot data=MY_DATA_SET;
format Act_Date date6.;
title 'Daily Chart for MY DATA SET';

ods graphics on / width=6.5in height=5.5in;

vbar Act_Date / response=Receipt_Count stat=sum group=Receipt_Code nostatlabel;
xaxis display= (no value);
yaxis grid;


I am using SAS Enterprise Guide 7.1 on a PC with Windows 7 Enterprise

Super User

If you want to control how many tick marks get labeled you can use the VALUES= option on the xaxis statement.


Xaxis values=('01JAN2020'd to '15FEB2020'd by week) ;


as an example. You supply the start and end dates you expect. The start is the more critical as that sets the first value to display and then the "by week" selects the remaining dates at 7 day intervals. The 'to' date just sets an upper likely limit if you happen to have data values for X that go past that date.


data example;
   do x= '01Jan2020'd to '31Mar2020'd;
      y= 50* rand('uniform');

proc sgplot data=example;
   series x=x y=y;
   format x  date6.;
   xaxis values=('03Jan2020'd to '15Feb2020'd by week);

You can use common calendar intervals such as week, month, quarter and year for by interval. This makes more sense if the xaxis variable is supposed to be a date.



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!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2 in conversation