BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ANWZimmerman
Obsidian | Level 7

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)

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

3 REPLIES 3
ANWZimmerman
Obsidian | Level 7

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

ballardw
Super User

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?

ANWZimmerman
Obsidian | Level 7

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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