[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: how to prevent SAS macro from interpreting "&"
From:       xlr82sas <xlr82sas () AOL ! COM>
Date:       2010-02-28 6:12:23
Message-ID: 3dafef65-035a-4c7d-be27-b351c4ca52e2 () s25g2000prd ! googlegroups ! com
[Download RAW message or body]

On Feb 26, 8:18 pm, xin...@STAT.PSU.EDU (xin) wrote:
> Hello, everyone:
> I am writing a string containing "&" into a macro variable. When I invoke
> this "&" containing macro variable in my code, SAS try to interpret
> this "&" as a presence of macro variable and as a result, gives warning
> msg "WARNING: Apparent symbolic reference XXXX not resolved". I am trying
> quote it with %bquote or %str, none of them works....
>
> thanks for any suggestion.

It is a little hard to offer a solution without seeing your code,
suppose you have

'Joe&Mikes realty Incorporated on &sysdate';

and you want sysdate to be resolved but not &Mikes.

%symdel ans;
%let mikes=Micheal;
%let res='Joe&Mikes realty Incorporated on &sysdate';
%let ans=%sysfunc(prxchange(s/.sysdate/&sysdate/,99,&res));
%put &ans;

'Joe&Mikes realty Incorporated on 25FEB10'

I like to keep the single quotes around until the last  resolution.
This way I control the content and timing of resolutions.

I  wish I could get back hours wasted on macro quoting functions.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic