<?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: merge two data sets in macro using proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merge-two-data-sets-in-macro-using-proc-sql/m-p/392874#M94584</link>
    <description>&lt;P&gt;Your code is working for me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data data1;&lt;BR /&gt;input y ;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;4&lt;BR /&gt;2&lt;BR /&gt;6&lt;BR /&gt;4&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data data2;&lt;BR /&gt;input y ;&lt;BR /&gt;datalines;&lt;BR /&gt;4&lt;BR /&gt;3&lt;BR /&gt;7&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;9&lt;BR /&gt;5&lt;BR /&gt;4&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;%MACRO createPlotData(data1 , data2);&lt;BR /&gt;proc sql;&lt;BR /&gt;create table plot1 as&lt;BR /&gt;select&lt;BR /&gt;y&lt;BR /&gt;from&lt;BR /&gt;&amp;amp;data1&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table plot2 as&lt;BR /&gt;select&lt;BR /&gt;y as y1&lt;BR /&gt;from&lt;BR /&gt;&amp;amp;data2&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data outputPlotData;&lt;BR /&gt;set plot1 plot2;&lt;BR /&gt;run;&lt;BR /&gt;%MEND;&lt;BR /&gt;%createPlotData(data1,data2)&lt;/P&gt;</description>
    <pubDate>Sun, 03 Sep 2017 20:22:15 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2017-09-03T20:22:15Z</dc:date>
    <item>
      <title>merge two data sets in macro using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-two-data-sets-in-macro-using-proc-sql/m-p/392873#M94583</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;today I wanted to merge two data sets together to finally draw some plots with the data. I got the code working outside of a macro, but as I have more data sets I wanted to create a macro for this:&lt;/P&gt;&lt;P&gt;Lets say I have data like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1;
   input y ;
   datalines;
    1
    2
    4
    2
    6
    4
    3
    4
;

data data2;
   input y ;
   datalines;
    4
    3
    7
    5
    6
    9
    5
    4
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now I want to merge the two data sets:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO createPlotData(data1 , data2); 
proc sql;
  create table plot1 as
  select
    y 
  from
   &amp;amp;data1
  ;
quit;
proc sql;
  create table plot2 as
  select
    y as y1
  from
   &amp;amp;data2
  ;
quit;

data outputPlotData;
     set plot1 plot2;
run;
%MEND;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The code is working when I use it outside of the macro. I already googeld and looked in this forum for a solution but I could not get the code to work. I think I need to at something inside the proc sql code?&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 20:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-two-data-sets-in-macro-using-proc-sql/m-p/392873#M94583</guid>
      <dc:creator>mrer</dc:creator>
      <dc:date>2017-09-03T20:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: merge two data sets in macro using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-two-data-sets-in-macro-using-proc-sql/m-p/392874#M94584</link>
      <description>&lt;P&gt;Your code is working for me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data data1;&lt;BR /&gt;input y ;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;4&lt;BR /&gt;2&lt;BR /&gt;6&lt;BR /&gt;4&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data data2;&lt;BR /&gt;input y ;&lt;BR /&gt;datalines;&lt;BR /&gt;4&lt;BR /&gt;3&lt;BR /&gt;7&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;9&lt;BR /&gt;5&lt;BR /&gt;4&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;%MACRO createPlotData(data1 , data2);&lt;BR /&gt;proc sql;&lt;BR /&gt;create table plot1 as&lt;BR /&gt;select&lt;BR /&gt;y&lt;BR /&gt;from&lt;BR /&gt;&amp;amp;data1&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table plot2 as&lt;BR /&gt;select&lt;BR /&gt;y as y1&lt;BR /&gt;from&lt;BR /&gt;&amp;amp;data2&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data outputPlotData;&lt;BR /&gt;set plot1 plot2;&lt;BR /&gt;run;&lt;BR /&gt;%MEND;&lt;BR /&gt;%createPlotData(data1,data2)&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2017 20:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-two-data-sets-in-macro-using-proc-sql/m-p/392874#M94584</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-09-03T20:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: merge two data sets in macro using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-two-data-sets-in-macro-using-proc-sql/m-p/392876#M94585</link>
      <description>True! **bleep** it... got confues by result pages which comes up automatically after running the code. It showed a different data set. thanks!</description>
      <pubDate>Sun, 03 Sep 2017 20:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-two-data-sets-in-macro-using-proc-sql/m-p/392876#M94585</guid>
      <dc:creator>mrer</dc:creator>
      <dc:date>2017-09-03T20:39:35Z</dc:date>
    </item>
  </channel>
</rss>

