BookmarkSubscribeRSS Feed
BillS
SAS Employee
I currently have a graph where I have broken expenditures down by month. What I am looking to do is add the current sum of all expenditures into the graph title.

I have been trying to use %sysfunc(sum(), so far unsuccessfully.

Should sysfunc work in this application? If not is there a way to do this?
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi, Bill:
%SYSFUNC will allow you to use DATA step functions. However, it seems to me that %SYSFUNC is the wrong function to use in this context.
A very frequent use of %SYSFUNC is something more like this:
[pre]
title "Today is: %sysfunc(today(),mmddyy10.)";
[/pre]

For what you want to do, you will have to get the summary number via another method (other than %SYSFUNC). The program below gets the average age of all the students in SASHELP.CLASS, by using PROC SQL and SELECT-INTO to create a macro variable which contains the average. Then, subsequent program steps can use that average in a TITLE statement (or in other statements). I just used a PROC PRINT instead of PROC GCHART, but you would be able to use the same technique with the Graph procedures. You just need to create a macro variable that holds your SUM -- before you use that macro variable in a TITLE statement.

cynthia
[pre]
proc sql;
select mean(age) format=5.2 into :avgage
from sashelp.class;
quit;

%let avgage = &avgage;
%put overall average age is: &avgage;

proc print data=sashelp.class;
title "Today is: %sysfunc(today(),mmddyy10.)";
title2 "The Average Age is &avgage";
run;
[/pre]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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