BookmarkSubscribeRSS Feed
B_rad
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;
run;

 

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

1 REPLY 1
ballardw
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');
      output;
   end;
run;

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

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1088 views
  • 0 likes
  • 2 in conversation