1

In SAS DIS I have set date parameters on a job. I tried setting the default values using the drop down menu provided, but each time I get the error

Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.

I therefore decided to try to check if the parameter is null before proceeding, but none of my various attempts succeeded. Is there a way to do this with user-written code? Something like

if(&date_param = .) then do;
date = today();
else do;
date = &date_param;
end;

I tried this within a macro and it did not work.

Much Gratitude.

Rookatu
  • 1,487
  • 3
  • 21
  • 50
  • I'm not a DIS expert, but am I right to guess that `&date_param` is a valid SAS macro variable (and is the parameter you're interested in)? – Joe Jun 02 '15 at 17:56

1 Answers1

2

Assuming this is similar to a standard SAS macro variable, a couple of things.

First off, a null parameter would be literally blank, not a period (that's for numeric dataset variables). In a data step you could check it like so:

if "&date_param." = " " then do;

Second, depending on context you may need to do this in macro syntax. If you're setting another parameter, you may need to do:

%if &date_param. eq  %then %do;
  %let date=%sysfunc(today());
%end;
%else %do;
  %let date = &date_param.;
%end;

%sysfunc lets you execute a data step function in macro code.

Joe
  • 62,789
  • 6
  • 49
  • 67
  • Hey Joe. Thanks for the advice. Trying your approach makes it so that the default values get populated when the parameters are missing (except that I checked for missing values using the approach at this link instead: http://changchung.com/download/022-2009.pdf). My problem is that when the parameters aren't missing the variable does not seem to take it's value. I'm passing the parameter from another SAS DIS job which loops over this one. Any ideas? – Rookatu Jun 02 '15 at 18:52
  • Unfortunately I don't know enough about how DIS works - it may be related to that, sorry. – Joe Jun 02 '15 at 21:09
  • @Joe I think it's better practice to remove the space in the dataset check so that it reads `if "&date_param." = "" then do;`. The reasoning behind this is that you can then do the exact same comparison in macro code (for consistency). ie. `%if "&x." = "" %then %do;`. This is also easier to read, debug and troubleshoot then the `eq %then` syntax. But that's just my opinion. – Robert Penridge Jun 02 '15 at 22:56
  • @Rookatu I can't understand your comment. %isblank from Chung and King should work fine in DIS. maybe show your code with %isblank as well as the section that generates the error?? – Quentin Jun 02 '15 at 23:07
  • I don't entirely disagree. In datastep code I prefer `" "` because it's technically accurate, and I wouldn't swap from one to the other generally. But in your use case it's not unreasonable of a solution certainly. – Joe Jun 02 '15 at 23:15
  • @Quentin I interpret that to mean the _assignment_ doesn't work (perhaps it's being overwritten?), not the Boolean. But unclear. – Joe Jun 02 '15 at 23:16