<?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 two SAS datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/283865#M57879</link>
    <description>Hello, I have 2 SAS datasets that I need to merge: one is called revenue and the other is called expenses. Each dataset contains the same 3 variable names: corp_stat, naics and prov_code which represent corporate status, industry and region respectively. To correctly match revenues and expenses, the 3 variables corp_stat, naics and prov_code must match so revenue &amp;amp; expenses match with their corresponding industry/region/corporate status. How would I code this? Would SQL or a merge statement be easier? Thanks Jack</description>
    <pubDate>Tue, 12 Jul 2016 18:35:32 GMT</pubDate>
    <dc:creator>Jack1</dc:creator>
    <dc:date>2016-07-12T18:35:32Z</dc:date>
    <item>
      <title>Merging two SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/283865#M57879</link>
      <description>Hello, I have 2 SAS datasets that I need to merge: one is called revenue and the other is called expenses. Each dataset contains the same 3 variable names: corp_stat, naics and prov_code which represent corporate status, industry and region respectively. To correctly match revenues and expenses, the 3 variables corp_stat, naics and prov_code must match so revenue &amp;amp; expenses match with their corresponding industry/region/corporate status. How would I code this? Would SQL or a merge statement be easier? Thanks Jack</description>
      <pubDate>Tue, 12 Jul 2016 18:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/283865#M57879</guid>
      <dc:creator>Jack1</dc:creator>
      <dc:date>2016-07-12T18:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/283873#M57884</link>
      <description>&lt;P&gt;The choice between Merge in a datastep and an SQL Join would usually come up when you have many to one or many to many questions. If there is only one of each then either should produce the same result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would probably use Proc SQL as that wouldn't require sorting the data first:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select a.*, b.expenses&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from revenuedataset as a left join expensedataset as b&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.corp_stat=b.corp_stat and a.naics=b.naics and a.prov_code=b.prov_code;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/283873#M57884</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-18T20:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/283965#M57922</link>
      <description>&lt;P&gt;If you are new enough to SAS to ask,&amp;nbsp;I reckon a data step is better. It gives much more information about how data&amp;nbsp;was processed, and its syntax is less prone to errors.&lt;/P&gt;
&lt;P&gt;SQL has a more natural syntax, but this apparent familiarity is misleading and it is very easy to *not* get the expected result.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 04:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/283965#M57922</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-13T04:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/284096#M57949</link>
      <description>&lt;P&gt;Thanks for the info....Jack&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 15:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/284096#M57949</guid>
      <dc:creator>Jack1</dc:creator>
      <dc:date>2016-07-13T15:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two SAS datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/284097#M57950</link>
      <description>&lt;P&gt;Thanks for the advice....Jack&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 15:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-SAS-datasets/m-p/284097#M57950</guid>
      <dc:creator>Jack1</dc:creator>
      <dc:date>2016-07-13T15:55:57Z</dc:date>
    </item>
  </channel>
</rss>

