still_learning
still_learning

Reputation: 806

How to consider a list of parameters as input field in a macro?

I have the following macro:

%macro create_table(TableFields=,TimeS=);
...
WHERE T1.TIME_S = &TIMES.
%mend create_table;

I would like to be able to consider multiple Time as follows: 39 51 63 ... in the input field, something like

%create_table(TableFields=id,TimeS=39 51 63);

unfortunately I am getting the following error message:

ERROR: Teradata prepare: Syntax error: expected something between an integer and the integer '51'. SQL statement was: SELECT

These values are included in WHERE T1.TIME_S = &TIMES. with TIMES defined as an interval: do i=&time_s_lower. to &time_s_upper.; Is it possible to list these values? If yes, how can I do this?

Thanks

Upvotes: 0

Views: 111

Answers (1)

Llex
Llex

Reputation: 1770

You should try to use IN operator in where clause instead of equal(=). It works with list of vars.

%macro create_table(TableFields=,TimeS=);
...
WHERE TIME_S IN (%sysfunc(tranwrd(&TimeS,%str( ),%str(,))));/*replace space with comma*/
%mend create_table;

%create_table(TableFields=id,TimeS=39 51 63);

Upvotes: 2

Related Questions