<?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 Appending dataset in Macro loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418744#M102889</link>
    <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to append the 100 files from test001-test100;&lt;/P&gt;
&lt;P&gt;when i run the below code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro append_all; &lt;BR /&gt;%do i=001 %to 194; &lt;BR /&gt;proc append base=final_mar data=test&amp;amp;i force; run; &lt;BR /&gt;%end;&lt;BR /&gt;%mend append_all;&lt;BR /&gt;%append_all;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the appending starts only from test100 file to test194... below 100 files are not appending what may be the reason?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Regards,&lt;/P&gt;
&lt;P&gt;Anil&lt;/P&gt;</description>
    <pubDate>Wed, 06 Dec 2017 10:37:44 GMT</pubDate>
    <dc:creator>anilgvdbm</dc:creator>
    <dc:date>2017-12-06T10:37:44Z</dc:date>
    <item>
      <title>Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418744#M102889</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to append the 100 files from test001-test100;&lt;/P&gt;
&lt;P&gt;when i run the below code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro append_all; &lt;BR /&gt;%do i=001 %to 194; &lt;BR /&gt;proc append base=final_mar data=test&amp;amp;i force; run; &lt;BR /&gt;%end;&lt;BR /&gt;%mend append_all;&lt;BR /&gt;%append_all;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the appending starts only from test100 file to test194... below 100 files are not appending what may be the reason?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Regards,&lt;/P&gt;
&lt;P&gt;Anil&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 10:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418744#M102889</guid>
      <dc:creator>anilgvdbm</dc:creator>
      <dc:date>2017-12-06T10:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418745#M102890</link>
      <description>&lt;P&gt;This question is asked a lot, and the root cause of it is mismanaged programming before this step.&amp;nbsp; How did you get 100 of datasets?&amp;nbsp; Whats the betting that you have done some sort of loop over some data and for each by group you have created a new dataset for output.&amp;nbsp; Your now stuck with a ton of datasets to append back together.&amp;nbsp; The simplest method is not to fight the programming language, use by grouping for ultimate performance and simpler coding.&amp;nbsp; For instance, if you were doing means like this:&lt;/P&gt;
&lt;PRE&gt;...
  %do i=1 %to 100;
    proc means data=...&lt;BR /&gt;      where bvar=&amp;amp;i.;
      output out=want&amp;amp;i.;
    run;
   %end;
...&lt;/PRE&gt;
&lt;P&gt;You would end up with 100 datasets all much the same, and then need to work with those.&amp;nbsp; You could use by grouping to vastly simplfy:&lt;/P&gt;
&lt;PRE&gt;proc means data=...
  by bvar;
  output out=want;
run;&lt;/PRE&gt;
&lt;P&gt;This produces one dataset, with all the first codes output information, grouped by the bvar variable.&amp;nbsp; You can then further process this without need to append lots of data.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 10:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418745#M102890</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-06T10:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418749#M102892</link>
      <description>&lt;P&gt;The leading zeros are automatically removed, because numbers don't have leading zeros.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best way to solve the issue is following &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; posts. If you can't fix the problem, try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro appending;
   %local dsn;
   
   %do dsn = 001 %to 194;
      %let dsn = %sysfunc(putn(&amp;amp;dsn, z3.));
      proc append base=work.complete new=work.a&amp;amp;dsn;
      run;
   %end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 11:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418749#M102892</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-12-06T11:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418846#M102934</link>
      <description>&lt;P&gt;Here is an example of what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43025"&gt;@error_prone&lt;/a&gt;&amp;nbsp;means about the values of your index variable:&lt;/P&gt;
&lt;PRE&gt;%macro dummy;
%do i=001 %to 194;
   %put macro variable i resolves to: &amp;amp;i;
%end;
%mend;
%dummy;&lt;/PRE&gt;
&lt;P&gt;The log will show what &amp;amp;i is as seen when resolved in loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 16:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418846#M102934</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-06T16:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Appending dataset in Macro loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418860#M102940</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set test001-test194;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 16:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-dataset-in-Macro-loop/m-p/418860#M102940</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-06T16:33:48Z</dc:date>
    </item>
  </channel>
</rss>

