08-28-2012 03:01 PM
In the SAS code below,the third one has a problem ,please advise.
%put a: &a;
%test(a=njhl5u#$%^&*(IJK44t95y7u45n64);/*This one has a problem*/
08-28-2012 03:12 PM
Special characters such as % & as a minimum get involved with the macro resolver. Depending on what you are actually trying to do you need to either mast or quote the string involving those characters. Look up %str() and the various macro quoting functions.
08-28-2012 03:42 PM
%put value of a is: &a;
%test(a=njhl5u#$%^&*IJK44t95y7u45n64); /*this one works*/
%test(a=njhl5u#$%^&*(IJK44t95y7u45n64);/*this one doesn't work*/
08-28-2012 03:43 PM
%put a: &a2;
08-28-2012 04:01 PM
Mike: I don't think it can be moved as ( had to be replaced with %( in calling the macro. However, I am definitely NOT an expert in macro quoting. You can find some good reading if you do a search for macro papers by either Ian Whitlock and/or Art Carpenter.
08-28-2012 04:04 PM
You have to do something.
Why not just use single quotes around the value? You can remove them when you need to.
Of course you still need watch out for strings that contain single quotes.
%test(a='Don''t forget to double the single quotes')