<?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: SAS macro question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511753#M137733</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100692"&gt;@Niugg2010&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding the missing semicolon after&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do k=1 %to &amp;amp;dsnnum.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would help a lot.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Nov 2018 17:31:00 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-11-09T17:31:00Z</dc:date>
    <item>
      <title>SAS macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511745#M137731</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;&lt;STRONG&gt;Below is my macro:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; try(dsns=);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; dsnnum=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;(countw("&amp;amp;dsns.", ' ,;:'));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; &amp;amp;dsnnum.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; k=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;dsnnum.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; dsn=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;(&amp;amp;dsns., &amp;amp;k., &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;( ,));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; &amp;amp;dsn.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;%&lt;STRONG&gt;&lt;I&gt;try&lt;/I&gt;&lt;/STRONG&gt;(dsns=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;(aaa, bbb, ccc))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;For the first loop, I want it &amp;amp;dsn=aaa, second loop &amp;amp;dsn=bbb, third loop &amp;amp;dsn=ccc;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;when I run above code, it produces some errors:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference K not resolved.&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference K not resolved.&lt;/P&gt;&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric&lt;/P&gt;&lt;P&gt;operand is required. The condition was: &amp;amp;k.&lt;/P&gt;&lt;P&gt;ERROR: Argument 2 to macro function %SCAN is not a number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;Someone can help me out?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;Thanks&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;George&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 17:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511745#M137731</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2018-11-09T17:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511750#M137732</link>
      <description>&lt;P&gt;Your first %LET statement has what appear to be unbalanced quotes.&amp;nbsp; Why are you using quotes anyway?&lt;/P&gt;
&lt;P&gt;Why are you making your task harder by adding commas in the value you are passing to macro?&lt;/P&gt;
&lt;P&gt;If it is a list of dataset names then just use spaces between the names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro try(dsns);
  %local dsnnum k dsn;
  %let dsnnum=%sysfunc(countw(&amp;amp;dsns,%str( )));
  %put &amp;amp;=dsnnum ;
  %do k=1 %to &amp;amp;dsnnum ;
    %let dsn=%scan(&amp;amp;dsns., &amp;amp;k., %str( ));
    %put &amp;amp;=k &amp;amp;=dsn;
  %end;
%mend try ;

%try(dsns=aaa bbb ccc)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Nov 2018 17:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511750#M137732</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-09T17:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511753#M137733</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100692"&gt;@Niugg2010&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding the missing semicolon after&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do k=1 %to &amp;amp;dsnnum.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would help a lot.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 17:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511753#M137733</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-09T17:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511760#M137739</link>
      <description>Got it. Thanks</description>
      <pubDate>Fri, 09 Nov 2018 17:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-question/m-p/511760#M137739</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2018-11-09T17:56:02Z</dc:date>
    </item>
  </channel>
</rss>

