<?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 Merging more than 2 data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-more-than-2-data-sets/m-p/397057#M278220</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to write a macro to merge more than 2 data sets (100 datasets to be exact), keeping only log-likelihood values in one column. Rather than type the name of every data set I tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge (n=100);
%Do i= 1 %TO &amp;amp;n;
%LET j=%EVAL(&amp;amp;i+1);
data LogLall;
set LogL&amp;amp;i LogL&amp;amp;j;
keep Log_Likelihood;
run;
%END;
%MEND;
%merge;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is only the final two datasets' values get saved to the new dataset. I want the final dataset to look as follows, but with 100 observations.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LogL.PNG" style="width: 203px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15282i629BA7F6C6E548D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="LogL.PNG" alt="LogL.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas how to save more than 2 datasets to the same file?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2017 10:00:02 GMT</pubDate>
    <dc:creator>aoifeoneill</dc:creator>
    <dc:date>2017-09-19T10:00:02Z</dc:date>
    <item>
      <title>Merging more than 2 data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-more-than-2-data-sets/m-p/397057#M278220</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to write a macro to merge more than 2 data sets (100 datasets to be exact), keeping only log-likelihood values in one column. Rather than type the name of every data set I tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge (n=100);
%Do i= 1 %TO &amp;amp;n;
%LET j=%EVAL(&amp;amp;i+1);
data LogLall;
set LogL&amp;amp;i LogL&amp;amp;j;
keep Log_Likelihood;
run;
%END;
%MEND;
%merge;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is only the final two datasets' values get saved to the new dataset. I want the final dataset to look as follows, but with 100 observations.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LogL.PNG" style="width: 203px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15282i629BA7F6C6E548D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="LogL.PNG" alt="LogL.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas how to save more than 2 datasets to the same file?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 10:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-more-than-2-data-sets/m-p/397057#M278220</guid>
      <dc:creator>aoifeoneill</dc:creator>
      <dc:date>2017-09-19T10:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merging more than 2 data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-more-than-2-data-sets/m-p/397061#M278221</link>
      <description>&lt;P&gt;Have you tried it without macros?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data LogLall;&lt;/P&gt;
&lt;P&gt;set LogL1-LogL100;&lt;/P&gt;
&lt;P&gt;keep Log_Likelihood;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only reason to add macro language would be to move the KEEP statement to the SET statement, along these lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set LogL1 (keep=Log_Likelihood) LogL2 (keep=Log_Likelihood) ... LogL100 (keep=Log_Likelihood);&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 10:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-more-than-2-data-sets/m-p/397061#M278221</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-19T10:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merging more than 2 data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-more-than-2-data-sets/m-p/397063#M278222</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;, I wasn't aware of '-' being available.</description>
      <pubDate>Tue, 19 Sep 2017 10:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-more-than-2-data-sets/m-p/397063#M278222</guid>
      <dc:creator>aoifeoneill</dc:creator>
      <dc:date>2017-09-19T10:19:41Z</dc:date>
    </item>
  </channel>
</rss>

