turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- GTL Conditional logic for flexible axes

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-03-2016 05:21 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ANWZimmerman

06-03-2016 06:23 PM

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?

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ANWZimmerman

06-03-2016 05:39 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ANWZimmerman

06-03-2016 06:23 PM

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

06-06-2016 10:20 AM

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