<?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 How to merge data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670429#M201255</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have about 48 data sets named&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g1_gr1&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g1_gr2&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g1_gr3&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g1_gr4&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g2_gr1&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g2_gr2&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;"g" goes up to 12.&lt;/P&gt;
&lt;P&gt;and "gr" goes up to 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to merge them based on the "g". For example one merged data set will include (pfreq_and_pl_g1_gr1,&amp;nbsp;pfreq_and_pl_g1_gr2,&amp;nbsp;pfreq_and_pl_g1_gr3,&amp;nbsp;pfreq_and_pl_g1_gr4), the other data set will include (pfreq_and_pl_g2_gr1,&amp;nbsp;pfreq_and_pl_g2_gr2,&amp;nbsp;pfreq_and_pl_g2_gr3,&amp;nbsp;pfreq_and_pl_g2_gr4).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Merging will be based on the data set's name, not a variable. How can I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Sun, 19 Jul 2020 06:44:19 GMT</pubDate>
    <dc:creator>dustychair</dc:creator>
    <dc:date>2020-07-19T06:44:19Z</dc:date>
    <item>
      <title>How to merge data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670429#M201255</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have about 48 data sets named&amp;nbsp;&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g1_gr1&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g1_gr2&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g1_gr3&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g1_gr4&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g2_gr1&lt;/P&gt;
&lt;P&gt;pfreq_and_pl_g2_gr2&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;"g" goes up to 12.&lt;/P&gt;
&lt;P&gt;and "gr" goes up to 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to merge them based on the "g". For example one merged data set will include (pfreq_and_pl_g1_gr1,&amp;nbsp;pfreq_and_pl_g1_gr2,&amp;nbsp;pfreq_and_pl_g1_gr3,&amp;nbsp;pfreq_and_pl_g1_gr4), the other data set will include (pfreq_and_pl_g2_gr1,&amp;nbsp;pfreq_and_pl_g2_gr2,&amp;nbsp;pfreq_and_pl_g2_gr3,&amp;nbsp;pfreq_and_pl_g2_gr4).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Merging will be based on the data set's name, not a variable. How can I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 06:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670429#M201255</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2020-07-19T06:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670431#M201256</link>
      <description>&lt;P&gt;If those datasets share the same structure, you probably want to.stack them, not merge.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 06:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670431#M201256</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-19T06:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670439#M201264</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;. I am sure there is an easier way to do that. Here is what I did. It worked but I still had to play a little bit in excel. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%macro combine(d);&lt;BR /&gt;&lt;BR /&gt;  %do i = 1 %to 12;&lt;BR /&gt;  data npfreq_and_pl_g&amp;amp;i._gr1;&lt;BR /&gt;  set npfreq_and_pl_g&amp;amp;i._gr1;&lt;BR /&gt;  group=1;&lt;BR /&gt;&lt;BR /&gt;  data npfreq_and_pl_g&amp;amp;i._gr2;&lt;BR /&gt;  set npfreq_and_pl_g&amp;amp;i._gr2;&lt;BR /&gt;  group=2;&lt;BR /&gt;&lt;BR /&gt;  data npfreq_and_pl_g&amp;amp;i._gr3;&lt;BR /&gt;  set npfreq_and_pl_g&amp;amp;i._gr3;&lt;BR /&gt;   group=3;&lt;BR /&gt;&lt;BR /&gt;  data npfreq_and_pl_g&amp;amp;i._gr4;&lt;BR /&gt;  set npfreq_and_pl_g&amp;amp;i._gr4;&lt;BR /&gt;  group=4;&lt;BR /&gt;run;&lt;BR /&gt;  data final_grade_&amp;amp;i.;&lt;BR /&gt;  set npfreq_and_pl_g&amp;amp;i._gr1 npfreq_and_pl_g&amp;amp;i._gr2 npfreq_and_pl_g&amp;amp;i._gr3 npfreq_and_pl_g&amp;amp;i._gr4; &lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%combine ;</description>
      <pubDate>Sun, 19 Jul 2020 07:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670439#M201264</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2020-07-19T07:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670440#M201265</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dsnames;
%do i = 1 %to 12;
&amp;nbsp; %do j = 1 %to 4;
&amp;nbsp;&amp;nbsp;npfreq_and_pl_g&amp;amp;i._gr&amp;amp;j.
&amp;nbsp; %end;
%end;
%mend;

data final_grade;
set
&amp;nbsp; %dsnames
&amp;nbsp; indsname=dsname
;
group = input(scan(dsname,-1,'r'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;not tested, posted from my tablet.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 08:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-data-sets/m-p/670440#M201265</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-19T08:34:29Z</dc:date>
    </item>
  </channel>
</rss>

