Prev: Reading an XML parsed file
Next: SAS Code
From: xlr82sas on 28 Feb 2010 01:12 On Feb 26, 8:18 pm, xin...(a)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.
From: Yu Zhang on 1 Mar 2010 12:18 On my WINXP SAS9.1, the code gives me error message, to me the '/' delimiter is an offending character. I tried different Marco quoting function and could not get it work. but it will work when i change the regular expression delimiter to '!'. Can someone verify to see if it will work on SAS9.2? %symdel ans; %let mikes=Micheal; %let res='Joe&Mikes realty Incorporated on &sysdate'; %let ans=%sysfunc(prxchange(s/. > > sysdate/&sysdate/,99,&res)); > %put &ans; > Thanks! Yu On Sun, Feb 28, 2010 at 12:12 AM, xlr82sas <xlr82sas(a)aol.com> wrote: > On Feb 26, 8:18 pm, xin...(a)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. >
From: xlr82sas on 1 Mar 2010 22:06 On Mar 1, 9:18 am, zhangy...(a)GMAIL.COM (Yu Zhang) wrote: > On my WINXP SAS9.1, the code gives me error message, to me the '/' delimiter > is an offending character. I tried different Marco quoting function and > could not get it work. but it will work when i change the regular expression > delimiter to '!'. > > Can someone verify to see if it will work on SAS9.2? > %symdel ans; > %let mikes=Micheal; > %let res='Joe&Mikes realty Incorporated on &sysdate'; > %let ans=%sysfunc(prxchange(s/. > > > > > sysdate/&sysdate/,99,&res)); > > %put &ans; > > Thanks! > > Yu > > > > On Sun, Feb 28, 2010 at 12:12 AM, xlr82sas <xlr82...(a)aol.com> wrote: > > On Feb 26, 8:18 pm, xin...(a)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.- Hide quoted text - > > - Show quoted text - Thanks a lot for educating me on the '!', I did not know that. It will be useful. I wonder about other aliases. !! also can be substituted for ||. ================================================================================= Yea it failed on my XP SAS. I think it is because SAS wants to devide. I don't have access to unix right now and I think my options may have something to do with why it worked on unix? Works with ! %symdel ans; %let mikes=Micheal; %let res='Joe&Mikes realty Incorporated on &sysdate'; %let ans=%sysfunc(prxchange(s!.sysdate!&sysdate!,99,&res)); %put &ans; 27 %symdel ans; 28 %let mikes=Micheal; 29 %let res='Joe&Mikes realty Incorporated on &sysdate'; 30 %let ans=%sysfunc(prxchange(s!.sysdate!&sysdate!,99,&res)); 31 %put &ans; 'Joe&Mikes realty Incorporated on 01MAR10' Works in the datastep ( with ! or / ) data _null_; res='Joe&Mikes realty Incorporated on &sysdate'; ans=prxchange("s!.sysdate!&sysdate!",99,res); put ans=; res='Joe&Mikes realty Incorporated on &sysdate'; ans=prxchange("s/.sysdate/&sysdate/",99,res); put ans=; run; 14 data _null_; 15 res='Joe&Mikes realty Incorporated on &sysdate'; 16 ans=prxchange("s!.sysdate!&sysdate!",99,res); 17 put ans=; 18 res='Joe&Mikes realty Incorporated on &sysdate'; 19 ans=prxchange("s/.sysdate/&sysdate/",99,res); 20 put ans=; 21 run; ans=Joe&Mikes realty Incorporated on 01MAR10 ans=Joe&Mikes realty Incorporated on 01MAR10 NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds Fails in XP %symdel ans; %let mikes=Micheal; %let res='Joe&Mikes realty Incorporated on &sysdate'; %let ans=%sysfunc(prxchange(s/.sysdate/&sysdate/,99,&res)); %put &ans; 22 %symdel ans; 23 %let mikes=Micheal; 24 %let res='Joe&Mikes realty Incorporated on &sysdate'; 25 %let ans=%sysfunc(prxchange(s/.sysdate/&sysdate/,99,&res)); ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: s/.sysdate/01MAR10/ ERROR: No pattern to process. ERROR: The regular expression passed to the function PRXCHANGE contains a syntax error. WARNING: Argument 1 to function PRXCHANGE referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range. 26 %put &ans;
From: xlr82sas on 1 Mar 2010 22:07 On Mar 1, 9:18 am, zhangy...(a)GMAIL.COM (Yu Zhang) wrote: > On my WINXP SAS9.1, the code gives me error message, to me the '/' delimiter > is an offending character. I tried different Marco quoting function and > could not get it work. but it will work when i change the regular expression > delimiter to '!'. > > Can someone verify to see if it will work on SAS9.2? > %symdel ans; > %let mikes=Micheal; > %let res='Joe&Mikes realty Incorporated on &sysdate'; > %let ans=%sysfunc(prxchange(s/. > > > > > sysdate/&sysdate/,99,&res)); > > %put &ans; > > Thanks! > > Yu > > > > On Sun, Feb 28, 2010 at 12:12 AM, xlr82sas <xlr82...(a)aol.com> wrote: > > On Feb 26, 8:18 pm, xin...(a)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.- Hide quoted text - > > - Show quoted text - I ran on SAS 9.1.3 will check 9.2 later tonight
From: xlr82sas on 1 Mar 2010 23:07 On Mar 1, 7:07 pm, xlr82sas <xlr82...(a)aol.com> wrote: > On Mar 1, 9:18 am, zhangy...(a)GMAIL.COM (Yu Zhang) wrote: > > > > > > > On my WINXP SAS9.1, the code gives me error message, to me the '/' delimiter > > is an offending character. I tried different Marco quoting function and > > could not get it work. but it will work when i change the regular expression > > delimiter to '!'. > > > Can someone verify to see if it will work on SAS9.2? > > %symdel ans; > > %let mikes=Micheal; > > %let res='Joe&Mikes realty Incorporated on &sysdate'; > > %let ans=%sysfunc(prxchange(s/. > > > > sysdate/&sysdate/,99,&res)); > > > %put &ans; > > > Thanks! > > > Yu > > > On Sun, Feb 28, 2010 at 12:12 AM, xlr82sas <xlr82...(a)aol.com> wrote: > > > On Feb 26, 8:18 pm, xin...(a)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.- Hide quoted text - > > > - Show quoted text - > > I ran on SAS 9.1.3 will check 9.2 later tonight- Hide quoted text - > > - Show quoted text - It works under 9.2 with the slashes 7041 %put &SYSVLONG4; 9.02.02M0P01152009 7042 %symdel ans; 7043 %let mikes=Micheal; 7044 %let res='Joe&Mikes realty Incorporated on &sysdate'; 7045 %let ans=%sysfunc(prxchange(s/.sysdate/&sysdate/,99,&res)); SYMBOLGEN: Macro variable SYSDATE resolves to 28FEB10 SYMBOLGEN: Macro variable RES resolves to 'Joe&Mikes realty Incorporated on &sysdate' 7046 %put &ans; SYMBOLGEN: Macro variable ANS resolves to 'Joe&Mikes realty Incorporated on 28FEB10' 'Joe&Mikes realty Incorporated on 28FEB10'
|
Pages: 1 Prev: Reading an XML parsed file Next: SAS Code |