s******r 发帖数: 1524 | 1 I have one macro written like
proc sql;
create table as
select %bquote("&&M&i") informat=$50. as test1,
cnt from
select * from connection to sql(
****
);
quit;run;
&&M&i is supposed to be : and (a>=1 and b>=2)
The code failed and log shows as
select "and ( a>=1 and b>=2)" informat= as test1,
$50. disappeared.
while I changed code to
proc sql;
create table as
select %bquote("&&M&i") as test1 informat=$50.,
cnt from
select * from connection to sql(
****
);
quit;run;
I got
"and (a>=1 and b>=2) "
_
22
___
202
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted
string, a numeric constant, a datetime constant,
a missing value, (, *, +, -, BTRIM, CALCULATED, CASE, EXISTS,
INPUT, NOT, PUT, SUBSTRING, TRANSLATE, USER, ^, ~.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
While I copied all log transferred SAS code and it actually works. Any idea
how to fix the problem?
Thank a lot. | a*****3 发帖数: 601 | | s******y 发帖数: 352 | 3
correct me if i am wrong. I don't think you need macro quoting here.
plus, you used double quotations as the argument for %bquote. the argument
will be resolved at the compile time, though you used a execution time
quoting function.
the resolved &&M&I will stay within the quotation marks.it will not cause
any problem at all. I can not see why you need to mask special characters.
the error message has nothing to do with the sql pass through as your select
statement is applied to the result set returned by the native database.
just use %unquote function to unquote the masked characters to see if it
will dismiss the error message. if not, you need to provide more information
.
【在 s******r 的大作中提到】 : I have one macro written like : proc sql; : create table as : select %bquote("&&M&i") informat=$50. as test1, : cnt from : select * from connection to sql( : **** : ); : quit;run; : &&M&i is supposed to be : and (a>=1 and b>=2)
| a*****3 发帖数: 601 | 4 and (a>=1 and b>=2) 是合法变量名么? 谁来说说? | s******y 发帖数: 352 | 5 To your question. yes, it is:
option validvarname=any;
data a;
'and (a>=1 and b>=2)'n='hello alex';
run;
proc contents;
run;
but I don't think OP wants to add a column with that name. my best guess is
OP want to pass a condition dynamically to somewhere.
BAOZI please! | a*****3 发帖数: 601 | 6 可是从log上看,宏变量似乎已经成功resolve了 。 no matter if any quoting
functions should be used or not.
: will be resolved at the compile time, though you used a execution time:
quoting function.
any problem at all. I can not see why you need to mask special characters.:
the error message has nothing to do with the sql pass through as your
select: statement is applied to the result set returned by the native
database.: just use %unquote function to unquote the masked characters to
see if it: will dismiss the error message. if not, you need to provide more
information
【在 s******y 的大作中提到】 : To your question. yes, it is: : option validvarname=any; : data a; : 'and (a>=1 and b>=2)'n='hello alex'; : run; : proc contents; : run; : but I don't think OP wants to add a column with that name. my best guess is : OP want to pass a condition dynamically to somewhere. : BAOZI please!
| s******y 发帖数: 352 | 7 Right. that is why I suggest to use %unquote to unmask the masked chars.
especially the "". most of time, the masked char will be automatically
unmasked so that the SAS tokenizer can parse the statement. but some time,
the auto conversion failed. so you need to unquote them manually.
BAOZI please.
.:
more
【在 a*****3 的大作中提到】 : 可是从log上看,宏变量似乎已经成功resolve了 。 no matter if any quoting : functions should be used or not. : : : will be resolved at the compile time, though you used a execution time: : quoting function. : any problem at all. I can not see why you need to mask special characters.: : the error message has nothing to do with the sql pass through as your : select: statement is applied to the result set returned by the native : database.: just use %unquote function to unquote the masked characters to : see if it: will dismiss the error message. if not, you need to provide more
| a*****3 发帖数: 601 | | s******y 发帖数: 352 | 9 还有2场。 下下星期的风险较高, 当然回报也高。 我是想all-in。 然后征些包子赌
第二场。 不然我早睡觉去了。不建议你参与这两次。 血本乌龟的可能性太高 | s******r 发帖数: 1524 | 10 yeah. You are right.
First time. It failed with double quote, I thought () could be the problem,
that's why I added %bquote, thought it would help.
Now it works with "", however still no clue why informat=$50. changed to
informat=,
select
information
【在 s******y 的大作中提到】 : 还有2场。 下下星期的风险较高, 当然回报也高。 我是想all-in。 然后征些包子赌 : 第二场。 不然我早睡觉去了。不建议你参与这两次。 血本乌龟的可能性太高
| s******r 发帖数: 1524 | 11 it is not what I want to do.
What I want to do is to create a report based on a table contents.
like how many record with c=3 or ( a>=1 and b>=2 )
how many c=3 or (a>=2 and b>=1)
is
【在 s******y 的大作中提到】 : To your question. yes, it is: : option validvarname=any; : data a; : 'and (a>=1 and b>=2)'n='hello alex'; : run; : proc contents; : run; : but I don't think OP wants to add a column with that name. my best guess is : OP want to pass a condition dynamically to somewhere. : BAOZI please!
| s******y 发帖数: 352 | 12 can you do something like this:
select sum(c=3 or ( a>=1 and b>=2 )) as condtion1,
sum(c=3 or (a>=2 and b>=1)) as condition2,...
from connect to sql ................
【在 s******r 的大作中提到】 : it is not what I want to do. : What I want to do is to create a report based on a table contents. : like how many record with c=3 or ( a>=1 and b>=2 ) : how many c=3 or (a>=2 and b>=1) : : is
| s******r 发帖数: 1524 | 13 It will be slow. I try to transfer minimum data from database.
【在 s******y 的大作中提到】 : can you do something like this: : select sum(c=3 or ( a>=1 and b>=2 )) as condtion1, : sum(c=3 or (a>=2 and b>=1)) as condition2,... : from connect to sql ................
|
|