Sample 52445: Use a macro to label specific tick mark values
The sample code on the
Full Code tab defines a macro to specify the values for the tick marks on a bar chart generated with the GBARLINE procedure, and only labels every third bar.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The sample code below defines a macro to specify the values for the tick marks on a bar chart generated with the GBARLINE procedure, and only labels every third bar.
/* Set the graphics environment */
goptions reset=all cback=white border htext=10pt htitle=12pt;
/* Create a macro variable for the Nth bar to be labeled */
%let labelbars=3;
proc sort data=sashelp.stocks out=stocks nodupkey;
by date;
run;
/* Create the values for the AXIS statement VALUE= option */
data _null_;
set stocks end=last;
/* If the bar should be labeled, assign the value of the midpoint, */
/* assuming that the first bar is always labeled */
if mod(_n_,&labelbars)=1
then call symputx(cat('ticklabel',_n_),put(date,date9.));
/* Otherwise assign a blank for the value */
else call symputx(cat('ticklabel',_n_),' ');
/* determine the number of midpoints */
if last then call symput('total',_n_);
run;
%macro tickvalues;
%do i=1 %to &total;
tick=&i "&&ticklabel&i"
%end;
%mend;
title 'Define a macro to label specific tick mark values';
symbol1 interpol=join color=black value=dot;
axis1 label=('Date') value=(%tickvalues);
proc gbarline data=sashelp.stocks;
vbar date / sumvar=open maxis=axis1;
plot / sumvar=close;
run;
quit;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample uses a macro to define the VALUE= option in an AXIS statement to change the values written at each tick mark.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GBARLINE
|
Date Modified: | 2014-03-21 15:51:53 |
Date Created: | 2014-02-27 08:41:20 |
Operating System and Release Information
SAS System | SAS/GRAPH | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
Microsoft® Windows® for x64 | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
Microsoft Windows XP Professional | 9.2 TS1M0 | |
Windows Vista | 9.2 TS1M0 | |
Windows Vista for x64 | 9.2 TS1M0 | |
64-bit Enabled AIX | 9.2 TS1M0 | |
64-bit Enabled HP-UX | 9.2 TS1M0 | |
64-bit Enabled Solaris | 9.2 TS1M0 | |
HP-UX IPF | 9.2 TS1M0 | |
Linux | 9.2 TS1M0 | |
Linux for x64 | 9.2 TS1M0 | |
OpenVMS on HP Integrity | 9.2 TS1M0 | |
Solaris for x64 | 9.2 TS1M0 | |