I have a Macro template for my graphs:
/*Generic GTL template for line graphs*/
%Macro CreateTemplate(statGraphName, yaxisOption, groupText, dataLabelText, rollNameText, /*linecolor,*/ yColumn);
/*color campus line graphs*/
%let colorline = %str(lineattrs = (pattern =1 thickness = 1));
%let colorsymbol = %str();
/*template*/
proc template;
define statgraph &statGraphName;
dynamic TITLE1 TITLE2;
begingraph;
entrytitle halign=left TITLE1;
entrytitle TITLE2;
layout overlay / xaxisopts =(label = ' ') &yaxisOption walldisplay=(fill);
seriesplot x=Fiscal_Year y=&yColumn / group=&groupText name='a' index=index display=all datalabel=&dataLabelText
&colorline &colorsymbol
&rollNameText;
endlayout;
endgraph;
end;
run;
%Mend;
And it is called with the following code:
%CreateTemplate(ProposalsDollarTemplate, %str(yaxisopts =(label = ' ' linearopts=(viewmin=0))), none, none,
%str(ROLENAME=(Year=Fiscal_Year)
TIP=(Year Y ) tiplabel=(Year="Fiscal Year" Y="# Proposals" )), _FREQ_);
/*display graph*/
proc sgrender data= ProposalsCombinedSummary template=ProposalsDollarTemplate;
dynamic title2="# of ¤tOrg Proposals Submitted-Fiscal YTD";
run;
Currently my graph is showing the x axis with decimal values (see image), and I want to display intergers only. Is there an easy option to add to my template to specifiy interger values? The actual values on the x axis will change, so I don't want any hard-coded values.i
In the LINEAROPTS of the axis options, there is an option called INTEGER=true | false that does just what you want.
Hi,
Not sure I undertand. Why do you have all the macro code there? Why not just use the flexibility of dynamic variables, and conditional logic in the template. As for your axis, why not just take round min - round max plus some window (maybe 10% of the range between min/max), again use a dynamic variable:
proc sgrender data= ProposalsCombinedSummary template=ProposalsDollarTemplate;
dynamic title2="# of ¤tOrg Proposals Submitted-Fiscal YTD"
range_low=&min. range_high=&max. range_window=&window.;
run;
In the LINEAROPTS of the axis options, there is an option called INTEGER=true | false that does just what you want.
Thank you! This worked perfectly!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.