开发者

macro value assign in sql server pass through

I'm trying to use the macrovariable in SAS开发者_StackOverflow社区 macro as value in the newcolumn for example :

%let macrovariable = value;

I would like to have every single value in newcolumn assign as value how can do that ? I have used this code below but end up get "&macrovariable" instead of "value".

SELECT CAST('&macrovariable.' as char) newcolumn


Try using double quotes, instead of single quotes.


So.. here's the answer ( just in case anyone wants to know )

SELECT CAST(%str(%')&macrovariable.%str(%') as char) newcolumn 

This way, it was actually force the macro read it with the single qotation before the pass-through sql server.

Very tricky and very fun - actually.


* Add single quotes around mv;
data _null_;
    call symput('mvsq',"'&mv.'");
run;
%put &mvsq; *debug;
...
select &mvsq. ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜