Hi @LinusH
I wrote a small program with relevant snippets from the transformation code to test the behaviour.
And you are right, a %put works, so the macro variable can resolve.
The error occurs in the proc freq statement when the macro variable is resolved as a data set option.
I can't figure out what happens, because it works if the same value is copied from the log (the %put &_INPUT_options) and used in the proc statement.
Code and log:
data test;
id = 1; state = 'OH';
run;
%let _INPUT = work.test;
%let _INPUT_options = %nrquote(WHERE = %(State = %'OH%'%));
%let procOptions = ;
%let etls_freqOrder = ;
%put &=_INPUT_options;
* As generated in the transformation - Fails;
proc freq data = &_INPUT (&_INPUT_options)
&procOptions &etls_freqOrder;
tables ID/ NOCOL NOFREQ ;
run;
* Test without extra options - Fails too;
proc freq data = &_INPUT (&_INPUT_options);
tables ID/ NOCOL NOFREQ ;
run;
* With the input option copied from the log (%put) - Works;
proc freq data = &_INPUT (WHERE = (State = 'OH'));
tables ID/ NOCOL NOFREQ ;
run;
136 data test;
137 id = 1; state = 'OH';
138 run;
NOTE: The data set WORK.TEST has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
139
140 %let _INPUT = work.test;
141 %let _INPUT_options = %nrquote(WHERE = %(State = %'OH%'%));
142 %let procOptions = ;
143 %let etls_freqOrder = ;
144
145 %put &=_INPUT_options;
_INPUT_OPTIONS=WHERE = (State = 'OH')
146
147 * As generated in the transformation - Fails;
148 proc freq data = &_INPUT (&_INPUT_options)
NOTE: Line generated by the macro variable "_INPUT_OPTIONS".
1 WHERE = (State = 'OH')
-
22
-
76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, (, *, +, -, :, INPUT, NOT,
PUT, ^, ~.
ERROR 76-322: Syntax error, statement will be ignored.
149 &procOptions &etls_freqOrder;
150 tables ID/ NOCOL NOFREQ ;
151 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
152
153 * Test without extra options - Fails too;
154 proc freq data = &_INPUT (&_INPUT_options);
NOTE: Line generated by the macro variable "_INPUT_OPTIONS".
1 WHERE = (State = 'OH')
-
22
-
76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, (, *, +, -, :, INPUT, NOT,
PUT, ^, ~.
ERROR 76-322: Syntax error, statement will be ignored.
155 tables ID/ NOCOL NOFREQ ;
156 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
157
158 * With the input option copied from the log (%put) - Works;
159 proc freq data = &_INPUT (WHERE = (State = 'OH'));
160 tables ID/ NOCOL NOFREQ ;
161 run;
NOTE: There were 1 observations read from the data set WORK.TEST.
WHERE State='OH';
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
... View more