<?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: create table/datset table using a macro variable. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603445#M174838</link>
    <description>&lt;P&gt;Hi and welcome to the SAS Community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need a macro to do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let _ctrlnum = '1000,2000,3000';

data temp(drop=i);
    length CNTRLNUM $8.;
    do i=1 to countw(&amp;amp;_ctrlnum.);
        CNTRLNUM=scan(&amp;amp;_ctrlnum., i, ',', '');
        output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Nov 2019 07:07:14 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-12T07:07:14Z</dc:date>
    <item>
      <title>create table/datset table using a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603440#M174834</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am trying to create a table out of a macro variable which is having about 100 values,seperated by comma delimeter.&lt;/P&gt;&lt;P&gt;eg: %let _num = '10000,20000,30000....';&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I tried the below piece of code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%let _ctrlnum = '1000,2000,3000';&lt;BR /&gt;%LOCAL I;&lt;BR /&gt;DATA TEMP;&lt;BR /&gt;LENGTH CNTRLNUM $8.;&lt;BR /&gt;%do i=1 %to %sysfunc(countw(&amp;amp;_ctrlnum));&lt;BR /&gt;CNTRLNUM = "%scan(&amp;amp;_ctrlnum, &amp;amp;i)";&lt;BR /&gt;output;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend generate;&lt;BR /&gt;%generate (CNTRLNUM = &amp;amp;_ctrlnum);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I am getting&amp;nbsp;the following&amp;nbsp;error:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ERROR: All positional parameters must precede keyword parameters.&lt;/P&gt;&lt;DIV class="sasNote"&gt;NOTE: Line generated by the macro variable "_CTRLNUM".&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;84 1000,2000,3000&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;____&lt;/DIV&gt;&lt;DIV class="sasError"&gt;18&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;STRONG&gt;Please suggest a new method or help me with this piece of code.&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Thanks in advance.&lt;/DIV&gt;</description>
      <pubDate>Tue, 12 Nov 2019 06:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603440#M174834</guid>
      <dc:creator>aparnaraju21150</dc:creator>
      <dc:date>2019-11-12T06:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: create table/datset table using a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603442#M174835</link>
      <description>&lt;P&gt;A macro program should look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro &amp;lt;macro_name&amp;gt; (positional_argument(s) , named_argument= );

    macro code, program code

%mend &amp;lt;macro_name&amp;gt;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You either did not post all your code or miss the &lt;STRONG&gt;%macro&lt;/STRONG&gt; statement.&lt;/P&gt;
&lt;P&gt;Arguments to macro execution (%&amp;lt;macro_name&amp;gt; statement) should be written:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;all positional arguments first in same order as defined in %macro statement then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;named arguments in any order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore your next code line failed&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%generate (CNTRLNUM = &amp;amp;_ctrlnum);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 07:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603442#M174835</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-11-12T07:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: create table/datset table using a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603445#M174838</link>
      <description>&lt;P&gt;Hi and welcome to the SAS Community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need a macro to do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let _ctrlnum = '1000,2000,3000';

data temp(drop=i);
    length CNTRLNUM $8.;
    do i=1 to countw(&amp;amp;_ctrlnum.);
        CNTRLNUM=scan(&amp;amp;_ctrlnum., i, ',', '');
        output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Nov 2019 07:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603445#M174838</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-12T07:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: create table/datset table using a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603448#M174840</link>
      <description>&lt;P&gt;Hi Shmuel,&lt;/P&gt;&lt;P&gt;sorry, I didn't post the "&amp;nbsp;%macro generate(CNTRLNUM=);"&lt;/P&gt;&lt;P&gt;The issue is the values in sas variable is being used from a front end for which the values may vary each time. So, I am not able to give the values in the code.&lt;/P&gt;&lt;P&gt;Can you please suggest any other way to create the table?&lt;/P&gt;&lt;P&gt;Thank You.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 07:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603448#M174840</guid>
      <dc:creator>aparnaraju21150</dc:creator>
      <dc:date>2019-11-12T07:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: create table/datset table using a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603452#M174844</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/239763"&gt;@aparnaraju21150&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Shmuel,&lt;/P&gt;
&lt;P&gt;sorry, I didn't post the "&amp;nbsp;%macro generate(CNTRLNUM=);"&lt;/P&gt;
&lt;P&gt;The issue is the values in sas variable is being used from a front end for which the values may vary each time. So, I am not able to give the values in the code.&lt;/P&gt;
&lt;P&gt;Can you please suggest any other way to create the table?&lt;/P&gt;
&lt;P&gt;Thank You.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;According to error message:&lt;/P&gt;
&lt;PRE&gt;ERROR: All positional parameters must precede keyword parameters.&lt;BR /&gt;           ===================================&lt;/PRE&gt;
&lt;P&gt;there are some positional arguments defined before the cntrlnum= (named argument = keywors parameter),&lt;/P&gt;
&lt;P&gt;i.e.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro generate( ? , ...?... ,CNTRLNUM=);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Check again the &lt;STRONG&gt;%macro&lt;/STRONG&gt; line statement.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 08:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-table-datset-table-using-a-macro-variable/m-p/603452#M174844</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-11-12T08:17:27Z</dc:date>
    </item>
  </channel>
</rss>

