GTL Dynamic variable with column name as value

Reply
Super Contributor
Posts: 253

GTL Dynamic variable with column name as value

I'm trying to use a dynamic variable in GTL to drive some logic (if a plot is printed), but it's also a column name (it's also used to determine what some elements of the plot are).  I don't seem to be able to validate whether the value in that dynamic is a particular value, though - it seems to only work when the name is not a column.

For example, this does not work properly:

proc template;

define statgraph test;

dynamic name;

  begingraph;

  layout overlay;

  scatterplot x=name y=weight;

  if (name="sex")

  axistable x=name value=weight;

  endif;

  endlayout;

  endgraph;

end;

run;

proc sgrender data=sashelp.class template=test;

dynamic name="sex";

run;

But this does work properly:

proc template;

define statgraph test;

dynamic name;

  begingraph;

  layout overlay;

  scatterplot x=sex  y=weight;

  if (name="me")

  axistable x=sex value=weight;

  endif;

  endlayout;

  endgraph;

end;

run;

proc sgrender data=sashelp.class template=test;

dynamic name="me";

run;

Any way to get this to work?

PROC Star
Posts: 1,325

Re: GTL Dynamic variable with column name as value

Posted in reply to snoopy369

Hi,

I don't have a solution, but a workaround.

In my GTL explorations, I haven't played much with dynamic variables. 

Instead I tend to just wrap the PROC TEMPLATE step and the SGRENDER into a single macro.

That way I can use macro parameters and conditional processing to build the PROC TEMPLATE code, rather than use dynamic variables.

The cost of course is that I have to compile a template every time I make a plot, rather than compile once with dynamic variables.  But that cost seems pretty low, and benefit is I understand the macro language already.

--Q.

Super Contributor
Posts: 253

Re: GTL Dynamic variable with column name as value

Unfortunately, in this project I'm running a few hundred thousand SGRENDERs, so that few microseconds actually matters...

Ask a Question
Discussion stats
  • 2 replies
  • 205 views
  • 0 likes
  • 2 in conversation