<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro works, but error message received. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11590#M1104</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually. you don't need function catx();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro com (a=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let a1=%scan(&amp;amp;a,1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=2 %to %sysfunc(countw(&amp;amp;a));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let a1=&amp;amp;a1.,%scan(&amp;amp;a,&amp;amp;i);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let a=&amp;amp;a1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put &amp;amp;a;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%com (a=a b c d)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Feb 2012 06:27:06 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2012-02-24T06:27:06Z</dc:date>
    <item>
      <title>Macro works, but error message received.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11585#M1099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The original discussion was on SAS-L. The OP wanted to replace blanks with ',' in his macro variable strings.&lt;/P&gt;&lt;P&gt;eg. Have: %let a=a b c d; Want a=a,b,c,d.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I came up with the following Macro:&lt;/P&gt;&lt;P&gt;%macro com (a=);&lt;/P&gt;&lt;P&gt;%let a1=;&lt;/P&gt;&lt;P&gt; %do i=1 %to %sysfunc(countw(&amp;amp;a));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let a1=%sysfunc(catx(%str(,),&amp;amp;a1,%scan(&amp;amp;a,&amp;amp;i)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let a=&amp;amp;a1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put &amp;amp;a;&lt;/P&gt;&lt;P&gt; %mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %com (a=a b c d)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works for the purpose, but it generate an error message as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: %SYSEVALF function has no expression to evaluate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me to figure it out why.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 17:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11585#M1099</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-02-23T17:15:03Z</dc:date>
    </item>
    <item>
      <title>Macro works, but error message received.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11586#M1100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haikuo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK, first I have to comment and then I'll make a guess as to the cause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a very dangerous macro to use.&amp;nbsp; It is missing this key statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%local a1 i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I were to call this macro, it would change the value of existing macro variables named &amp;amp;A1 or &amp;amp;I.&amp;nbsp; Those macro variables might exist in the %GLOBAL symbol table, or they might exist in the %LOCAL symbol table for a macro that calls this macro.&amp;nbsp; But that is what makes this macro dangerous to use. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My guess as to where the error comes from is the first pass through the %DO loop, when &amp;amp;A1 is null.&amp;nbsp; To test this (I can't, I'm home today), try these changes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's there now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let a1=;&lt;/P&gt;&lt;P&gt;%do i=1 %to ...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let a1=%scan(&amp;amp;a,1);&lt;/P&gt;&lt;P&gt;%do i=2 %to ...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See if the error disappears.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 17:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11586#M1100</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-02-23T17:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro works, but error message received.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11587#M1101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks, Astounding. Comments well received. So What it means is that %sysfunc has problem with macro variable of null value, but still process it reluctanly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 17:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11587#M1101</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-02-23T17:49:59Z</dc:date>
    </item>
    <item>
      <title>Macro works, but error message received.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11588#M1102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysfunc in combination with catx is calling %sysevalf in a way that we cannot see.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a sort of a black box.&amp;nbsp; We can see what goes in and what comes out, but can only guess at the internal workings. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 17:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11588#M1102</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-02-23T17:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro works, but error message received.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11589#M1103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let a=1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 3&amp;nbsp; 4;&lt;/P&gt;&lt;P&gt;16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put original -&amp;gt; &amp;amp;a;&lt;/P&gt;&lt;P&gt;original -&amp;gt; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 3&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let a=%sysfunc(prxchange(%quote(s/\s+/,/),-1,&amp;amp;a));&lt;/P&gt;&lt;P&gt;19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put prxchange -&amp;gt; &amp;amp;a;&lt;/P&gt;&lt;P&gt;prxchange -&amp;gt; 1,2,3,4&lt;/P&gt;&lt;P&gt;20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;21&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let a=%sysfunc(translate(%quote(&amp;amp;a),'2c'x,'20'x));&lt;/P&gt;&lt;P&gt;22&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put translate -&amp;gt; &amp;amp;a;&lt;/P&gt;&lt;P&gt;translate -&amp;gt; 1,2,3,4&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 18:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11589#M1103</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-02-23T18:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Macro works, but error message received.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11590#M1104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually. you don't need function catx();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro com (a=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let a1=%scan(&amp;amp;a,1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=2 %to %sysfunc(countw(&amp;amp;a));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let a1=&amp;amp;a1.,%scan(&amp;amp;a,&amp;amp;i);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let a=&amp;amp;a1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put &amp;amp;a;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%com (a=a b c d)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 06:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11590#M1104</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-02-24T06:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro works, but error message received.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11591#M1105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Good call, Ksharp!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 12:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-works-but-error-message-received/m-p/11591#M1105</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-02-24T12:39:25Z</dc:date>
    </item>
  </channel>
</rss>

