Data visualization with SAS programming

GTL Conditional logic for flexible axes

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

GTL Conditional logic for flexible axes

I'm working on a template that may have on the xaxes either an integer that is a count of months, or a SAS date.

 

I need different options for these.

 

I had hoped I could put both my LINEAROPTS and my TIMEOPTS on the same COLUMNAXIS statement thinking that SGRENDER would pick the ones that make sense and ignore the other.  Didn't work out.

 

I know my SAS dates have a MONYY type format, so I turned to conditional logic like follows:

 

if (vformatn(_X) = "MONYY")

      columnaxes;

      columnaxis / griddisplay=on timeopts=(minorgrid=true minorticks=true minortickinterval=month);

   endcolumnaxes;

else

      columnaxes;

      columnaxis / griddisplay=on linearopts=(minorgrid=true);

   endcolumnaxes;

endif;/*sas date or not*/

 

But this isn't working as expected.  If I pass a linear value for _X it's fine, but if I pass a SAS date I don't get my axes options and I'm struggling to figure out why. 

 

Thanks (SAS 9.4 M3)


Accepted Solutions
Solution
‎06-06-2016 10:21 AM
Grand Advisor
Posts: 10,251

Re: GTL Conditional logic for flexible axes

From the GTL documentation:

SAS functions that can be used in a WHERE expression include

  • character handling functions
  • date and time functions
  • mathematical and statistical functions.

Note: Not all SAS functions are available in WHERE expressions. Call routines and other DATA-step-only functions (for example, LAG, VNAME, OPEN) are some examples of functions that cannot be used.

 

Since they explicitly state VNAME isn't available I would extend that to all of the variable information functions. So make the value a parameter that can be passed to the GTL.

I suspect that you were getting things to work for the "numeric" values as the compare always failed and the else behavior kicked in. Did you look for any notes in the log when the template was compiled?

View solution in original post


All Replies
Contributor
Posts: 29

Re: GTL Conditional logic for flexible axes

Oh, it wasn't super clear to me if I wanted FORMATN or FORMATNX so I tried both, neither worked.

Solution
‎06-06-2016 10:21 AM
Grand Advisor
Posts: 10,251

Re: GTL Conditional logic for flexible axes

From the GTL documentation:

SAS functions that can be used in a WHERE expression include

  • character handling functions
  • date and time functions
  • mathematical and statistical functions.

Note: Not all SAS functions are available in WHERE expressions. Call routines and other DATA-step-only functions (for example, LAG, VNAME, OPEN) are some examples of functions that cannot be used.

 

Since they explicitly state VNAME isn't available I would extend that to all of the variable information functions. So make the value a parameter that can be passed to the GTL.

I suspect that you were getting things to work for the "numeric" values as the compare always failed and the else behavior kicked in. Did you look for any notes in the log when the template was compiled?

Contributor
Posts: 29

Re: GTL Conditional logic for flexible axes

That was the problem.  I missed that.  So my solution was to add this to my code:

 

data _NULL_;

set &dsn;

call symput('xform',(vformatn(&x)));

run;

 

Then I can pass the value of &xform into GTL for the conditional logic and now it works perfectly!

 

Thanks

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 227 views
  • 0 likes
  • 2 in conversation