<?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 running merging code on multiple data at once in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511474#M137636</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE table fd5
 as select
 one.enrolid as id1,
 k5.enrolid as id2,
 one.age as age1,
 k5.age as age2,
 from one, k5
 where (one.age=k5.age);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the same data for multiple years: data names k5-k15 (10 yrs)&lt;/P&gt;&lt;P&gt;I want to run the above code on each year at once to create the output datasets&amp;nbsp;fd5- fd15&lt;/P&gt;&lt;P&gt;Any help is much appreciated!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Nov 2018 18:39:49 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2018-11-08T18:39:49Z</dc:date>
    <item>
      <title>running merging code on multiple data at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511474#M137636</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE table fd5
 as select
 one.enrolid as id1,
 k5.enrolid as id2,
 one.age as age1,
 k5.age as age2,
 from one, k5
 where (one.age=k5.age);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the same data for multiple years: data names k5-k15 (10 yrs)&lt;/P&gt;&lt;P&gt;I want to run the above code on each year at once to create the output datasets&amp;nbsp;fd5- fd15&lt;/P&gt;&lt;P&gt;Any help is much appreciated!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 18:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511474#M137636</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-11-08T18:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: running merging code on multiple data at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511475#M137637</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dothis;
%do yr=5 %to 15;
PROC SQL;
CREATE table fd&amp;amp;yr
 as select
 one.enrolid as id1,
 k&amp;amp;yr.enrolid as id2,
 one.age as age1,
 k&amp;amp;yr.age as age2,
 from one, k&amp;amp;yr
 where (one.age=k&amp;amp;yr.age);
quit;
%end;
%mend;

options mprint;
%dothis&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I always point out that its probably not the best idea to put data (the year) into a data set name as you have done here. Better to put the year value into a data set variable, and then the coding becomes much simpler and probably doesn't require any looping and doesn't require any macros. You really ought to go down that path next time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 18:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511475#M137637</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-08T18:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: running merging code on multiple data at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511479#M137639</link>
      <description>&lt;P&gt;1. Turn it into a macro&lt;BR /&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2. Combine data sets (append) and do it once instead of 10 times.&lt;/P&gt;
&lt;P&gt;3. Change it to a join with an ON instead of cross join to speed things up.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 18:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511479#M137639</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-08T18:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: running merging code on multiple data at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511587#M137695</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data FD5
     FD6
     FD7;
 merge ONE(in=A) 
       K5(in=K5 rename=(ENROLID=ID5))
       K6(in=K6 rename=(ENROLID=ID6))
       K7(in=K7 rename=(ENROLID=ID7)); 
 by AGE;
 if A &amp;amp; K5 then output FD5;
 if A &amp;amp; K6 then output FD6;
 if A &amp;amp; K7 then output FD7;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Nov 2018 03:00:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/running-merging-code-on-multiple-data-at-once/m-p/511587#M137695</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-11-09T03:00:03Z</dc:date>
    </item>
  </channel>
</rss>

