I'm trying to use proc template to create a template with a bunch of dynamic variables. Those variables work fine when I use them in most places, but when I try to use one in tickdisplaylist=(<DYNAMIC VARIABLE HERE>), it errors out and tells me it's expected a quoted string. In my sgrender call, I've tried quoting, not-quoting, embedding all of my quoted labels inside one big set of quotes, etc, but have not had success getting proc template to use my dynamic variable inside this option. Does anyone have any thoughts?
define statgraph GRPHNM; dynamic PLOT1_VISITS PLOT_UNIT PLOT1_YVAL PLOT1_XVAL PLOT2_YVAL PLOT_GROUPS; begingraph / datacolors = (&CLRSCALE) datacontrastcolors = (&CLRSCALE_CON.); /*entrytitle "Test plot for &PARMTOPLOT";*/ layout lattice / rows = 1 columns = 2 rowgutter = 0 columngutter = 2 columnweights = (0.66 0.34); /*** Standard plot ***/ layout overlay / xaxisopts=(linearopts=( viewmin = -2.5 viewmax = 26.5 tickvaluelist=(0 24) tickdisplaylist=("Baseline" "Week 24") ) display=(LINE TICKVALUES) ) yaxisopts=(label = PLOT_UNIT labelattrs=(size = 8pt) labelposition = TOP); scatterplot y=PLOT1_YVAL x= PLOT1_XVAL / group = PLOT_GROUPS jitter = AUTO groupdisplay = CLUSTER grouporder = &GORDER clusterwidth = 0.75 markerattrs=(size = 4 symbol = CIRCLEFILLED) datatransparency = 0.3 ; ...MORE PLOTS HERE... endlayout;
....CONTINUED...
To use dynamic variables to specify a tick value list and a tick display list, specify the dynamic variable names in TICKVALUELIST= and TICKDISPLAYLIST= without the parentheses. Here's an example:
proc template;
define statgraph scatterplot;
begingraph;
dynamic TICKVALLIST TICKDISPLIST
entrytitle "Height and Weight by Sex";
layout overlay /
xaxisopts=(linearopts=(tickvaluepriority=true
tickvaluelist=TICKVALLIST tickdisplaylist=TICKDISPLIST));
scatterplot x=height y=weight /
group=sex name="scatter" datalabel=name;
discretelegend "scatter";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=scatterplot;
dynamic TICKVALLIST="50 60 70" TICKDISPLIST="A B C";
run;
Give that a try.
For more information, see Referencing Dynamic Variables and Macro Variables in SAS Graph Template Language: User's Guide.
You might get a better response by 1) providing data or use of a SAS supplied data set like SASHELP.CLASS or CARS, 2) a complete template code and 3) the associated Proc SGRender.
I don't see any defined Dynamic variable that is used with TICKDISPLAYLIST.
A simple example with a single plot would probably be the starting point and just the TICKDISPLAYLIST as the only dynamic variable might be start.
To use dynamic variables to specify a tick value list and a tick display list, specify the dynamic variable names in TICKVALUELIST= and TICKDISPLAYLIST= without the parentheses. Here's an example:
proc template;
define statgraph scatterplot;
begingraph;
dynamic TICKVALLIST TICKDISPLIST
entrytitle "Height and Weight by Sex";
layout overlay /
xaxisopts=(linearopts=(tickvaluepriority=true
tickvaluelist=TICKVALLIST tickdisplaylist=TICKDISPLIST));
scatterplot x=height y=weight /
group=sex name="scatter" datalabel=name;
discretelegend "scatter";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=scatterplot;
dynamic TICKVALLIST="50 60 70" TICKDISPLIST="A B C";
run;
Give that a try.
For more information, see Referencing Dynamic Variables and Macro Variables in SAS Graph Template Language: User's Guide.
Thank you!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.