<?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: MaCRO in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233547#M5781</link>
    <description>Why are you doing this via a macro? It seems like a single/simple data step would work?</description>
    <pubDate>Fri, 06 Nov 2015 20:34:38 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-11-06T20:34:38Z</dc:date>
    <item>
      <title>MaCRO</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233534#M5779</link>
      <description>&lt;P&gt;Hello, I have 3 excel data sets named data 1,data 2 and data 3 with common variable id. I have imported them using MACRO. I have merged (data 1 ,data 2 and data 3 data 2) in the following way,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro merge (factor,m,n);&lt;/P&gt;
&lt;P&gt;data &amp;amp;factor;&lt;/P&gt;
&lt;P&gt;merge %do i = &amp;amp;m %to &amp;amp;n;&lt;/P&gt;
&lt;P&gt;data&amp;amp;i&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc print data = &amp;amp;factor;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%mend merge;&lt;/P&gt;
&lt;P&gt;%merge (combine1, 1,2);&lt;/P&gt;
&lt;P&gt;%merge (combine2, 2,3);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, I need to solve this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. merge data 1 and data 2 so that I have records only for those values of ID that are in data 1.&lt;/P&gt;
&lt;P&gt;2. merge all three files so that I have records only for those values of ID that are in all 3 datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I write the SAS MACRO code for these?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 19:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233534#M5779</guid>
      <dc:creator>docsaurmi</dc:creator>
      <dc:date>2015-11-06T19:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: MaCRO</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233537#M5780</link>
      <description>&lt;P&gt;You should use the IN option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://onlinecourses.science.psu.edu/stat481/node/18" target="_blank"&gt;https://onlinecourses.science.psu.edu/stat481/node/18&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 20:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233537#M5780</guid>
      <dc:creator>slangan</dc:creator>
      <dc:date>2015-11-06T20:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: MaCRO</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233547#M5781</link>
      <description>Why are you doing this via a macro? It seems like a single/simple data step would work?</description>
      <pubDate>Fri, 06 Nov 2015 20:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233547#M5781</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-06T20:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: MaCRO</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233552#M5782</link>
      <description>&lt;P&gt;How can I use 'in' option in MACRO code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 20:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233552#M5782</guid>
      <dc:creator>docsaurmi</dc:creator>
      <dc:date>2015-11-06T20:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: MaCRO</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233555#M5783</link>
      <description>&lt;P&gt;I am just trying to use MACRO in this case.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 20:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233555#M5783</guid>
      <dc:creator>docsaurmi</dc:creator>
      <dc:date>2015-11-06T20:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: MaCRO</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233560#M5784</link>
      <description>&lt;P&gt;This is actually a good exercise to use, to learn more about writing macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, this line in your macro will change:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data&amp;amp;i&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, it will add the IN= variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data&amp;amp;i (in=in&amp;amp;i)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The other piece that changes is a bit more complex.&amp;nbsp; It will add a statement after the BY statement, to subset observations.&amp;nbsp; It will genereate something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if in1 and in2 and in3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do that, all of this code goes between the BY statement and the RUN statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if&lt;/P&gt;
&lt;P&gt;%do i=&amp;amp;m to &amp;amp;n;&lt;/P&gt;
&lt;P&gt;in&amp;amp;i&lt;/P&gt;
&lt;P&gt;%if &amp;amp;i &amp;lt; &amp;amp;n %then and;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try to match up the pieces of the macro version to the pieces of the hard-coded IF statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 21:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233560#M5784</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-11-06T21:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: MaCRO</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233600#M5789</link>
      <description>&lt;P&gt;Below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge (factor,m,n);

  data &amp;amp;factor;
    merge 
      %do i = &amp;amp;m %to &amp;amp;n;
        data&amp;amp;i (in=in&amp;amp;i)
      %end;
      ;
    by id;

    %do i = &amp;amp;m %to &amp;amp;n;
      if in&amp;amp;i;
    %end;

  run;

  proc print data = &amp;amp;factor;
  run;

%mend merge;

%merge (combine1, 1,2);
%merge (combine2, 2,3);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Nov 2015 03:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/MaCRO/m-p/233600#M5789</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-07T03:11:02Z</dc:date>
    </item>
  </channel>
</rss>

