<?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 macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macros/m-p/240851#M268359</link>
    <description>&lt;P&gt;%macro print(libname,dslist=a b c);&lt;BR /&gt;%do i=1 %to 4;&lt;BR /&gt;proc print data=&amp;amp;libname..%scan(&amp;amp;dslist,&amp;amp;i);&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%print(pawan,dslist=test p1 test1 test2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here if i place quotes in (dslist="test p1 test1 test2") it's not working..........in which scenerio have to place quotes and not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro print1(libname,dslist="pawan test test1");&lt;BR /&gt;%do i=1 %to 4;&lt;BR /&gt;data _null_;&lt;BR /&gt;call symput('a',scan(&amp;amp;dslist,&amp;amp;i));&lt;BR /&gt;run;&lt;BR /&gt;proc print data=&amp;amp;libname..&amp;amp;a;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;here it is not working without quotes?&lt;/P&gt;</description>
    <pubDate>Fri, 25 Dec 2015 05:58:07 GMT</pubDate>
    <dc:creator>pawandh</dc:creator>
    <dc:date>2015-12-25T05:58:07Z</dc:date>
    <item>
      <title>macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macros/m-p/240851#M268359</link>
      <description>&lt;P&gt;%macro print(libname,dslist=a b c);&lt;BR /&gt;%do i=1 %to 4;&lt;BR /&gt;proc print data=&amp;amp;libname..%scan(&amp;amp;dslist,&amp;amp;i);&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%print(pawan,dslist=test p1 test1 test2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here if i place quotes in (dslist="test p1 test1 test2") it's not working..........in which scenerio have to place quotes and not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro print1(libname,dslist="pawan test test1");&lt;BR /&gt;%do i=1 %to 4;&lt;BR /&gt;data _null_;&lt;BR /&gt;call symput('a',scan(&amp;amp;dslist,&amp;amp;i));&lt;BR /&gt;run;&lt;BR /&gt;proc print data=&amp;amp;libname..&amp;amp;a;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;here it is not working without quotes?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2015 05:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macros/m-p/240851#M268359</guid>
      <dc:creator>pawandh</dc:creator>
      <dc:date>2015-12-25T05:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macros/m-p/240853#M268360</link>
      <description>&lt;P&gt;Then put double quote into separator list and remain&amp;nbsp;the validate variable name .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro print(libname,dslist=a b c);
%do i=1 %to 4;
 %put &amp;amp;libname..%scan(&amp;amp;dslist,&amp;amp;i,,kdf);
%end;
%mend;


%print(pawan,dslist=test p1 test1 test2)

%print(pawan,dslist="test p1 test1 test2")&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Dec 2015 06:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macros/m-p/240853#M268360</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-12-25T06:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macros/m-p/240868#M268361</link>
      <description>&lt;P&gt;Always, always always ... when you use macro language you have to picture what the program is going to look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While KSharp gave you a correct answer, here is some of the reasoning behind it. &amp;nbsp;Picture the result of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dslist="test&amp;nbsp;pi&amp;nbsp;test1 test2"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When %scan operates on this string, the first word in the list is "test and the last word is test2". &amp;nbsp;If you pictured that, you would expect to get an error for coding data=&amp;amp;libname.."test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;KSharp correctly noted that you can add doublequotes to your list of delimeters that %can uses, so that the first word woul be test instead of "test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you switch to a DATA step, the SCAN function expects to see a character string as the first parameter. &amp;nbsp;So the first word within "test pi test1 test2" would be test and not "test. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I expect that you have a solution for your problem now, as well as what you need to do to avoid future problems.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2015 17:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macros/m-p/240868#M268361</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-25T17:57:20Z</dc:date>
    </item>
  </channel>
</rss>

