Rookatu
Rookatu

Reputation: 1507

Check if a SAS DIS parameter is null

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.

Upvotes: 1

Views: 894

Answers (1)

Joe
Joe

Reputation: 63424

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.

Upvotes: 2

Related Questions