<?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: How to merge 2 datasets that are the same in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408321#M99633</link>
    <description>&lt;P&gt;Are you sure you want to merge and not concatenate the two datasets?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data compustat_1;
 set transform transform2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the variable that is different?&amp;nbsp; Is it only one variable in one dataset? Or one variable in each dataset?&amp;nbsp; If in both does it have different names in both datasets?&amp;nbsp; If it does have the same name in both datasets then which value do you want to appear in the result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are merging do the only want observations that are in both? Or observations that are either?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are your actual key variables that uniquely identify the observations in each file?&amp;nbsp; What is the purpose of the other variables?&lt;/P&gt;
&lt;P&gt;Or do you have multiple observations per key value?&amp;nbsp; If so is it multiple observations in both input datasets? Or only in one?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 29 Oct 2017 05:44:05 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-10-29T05:44:05Z</dc:date>
    <item>
      <title>How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/407907#M99445</link>
      <description>&lt;P&gt;I've tried regular merging and this proc sql but my observations end up getting deleted. The datasets have the same columns except for 1 but I want it all to be in one data set. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/**proc sql;&lt;BR /&gt;create table compustat_1 as&lt;BR /&gt;select *&lt;BR /&gt;from transform a, transform2 b&lt;BR /&gt;where a.gvkey=b.gvkey and&lt;BR /&gt;a.datadate=b.datadate and a.fyear=b.fyear and a.cusip=b.cusip and a.conm=b.conm&lt;BR /&gt;and a.fyr=b.fyr and a.CIKold=b.CIKold and a.cik=b.cik and a.ni=b.ni and a.revt=b.revt and&lt;BR /&gt;a.SICCODE=b.SICCODE and a.count=b.count and a.log_count=b.log_count and a.Size=b.Size and a.ROA-b.ROA;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;**//&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 04:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/407907#M99445</guid>
      <dc:creator>dlazer1</dc:creator>
      <dc:date>2017-10-27T04:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/407910#M99447</link>
      <description>&lt;P&gt;1. Is there any errors in the log - post the full log.&lt;/P&gt;
&lt;P&gt;2. Check your types/formats on the variables, does it match for all your key variables&lt;/P&gt;
&lt;P&gt;3. You're doing a cross join and then filtering. Try specifying the join type instead (full/left/right) and using an ON clause instead of a WHERE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Show your data step version and the log, I find that better and showing errors.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 04:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/407910#M99447</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-27T04:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/407911#M99448</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table compustat_1 as
select *
from 
	transform natural join transform2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 04:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/407911#M99448</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-27T04:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408313#M99627</link>
      <description>&lt;P&gt;That didn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;188 proc sql;&lt;BR /&gt;189 create table compustat_1 as&lt;BR /&gt;190 select *&lt;BR /&gt;191 from transform natural join transform2;&lt;BR /&gt;NOTE: Table WORK.COMPUSTAT_1 created, with 0 rows and 18 columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 02:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408313#M99627</guid>
      <dc:creator>dlazer1</dc:creator>
      <dc:date>2017-10-29T02:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408314#M99628</link>
      <description>&lt;P&gt;***on**** didnt work either&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;193 proc sql;&lt;BR /&gt;194 create table compustat_1 as&lt;BR /&gt;195 select *&lt;BR /&gt;196 from transform a, transform2 b&lt;BR /&gt;197 on a.gvkey=b.gvkey and&lt;BR /&gt;--&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, ',', ANSIMISS, CROSS, EXCEPT, FULL,&lt;BR /&gt;GROUP, HAVING, INNER, INTERSECT, JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT,&lt;BR /&gt;UNION, WHERE.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;198 a.datadate=b.datadate and a.fyear=b.fyear and a.cusip=b.cusip and a.conm=b.conm&lt;BR /&gt;199 and a.fyr=b.fyr and a.CIKold=b.CIKold and a.cik=b.cik and a.ni=b.ni and a.revt=b.revt and&lt;BR /&gt;200 a.SICCODE=b.SICCODE and a.count=b.count and a.log_count=b.log_count and a.Size=b.Size and&lt;BR /&gt;200! a.ROA-b.ROA;&lt;BR /&gt;201 quit;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 02:25:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408314#M99628</guid>
      <dc:creator>dlazer1</dc:creator>
      <dc:date>2017-10-29T02:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408315#M99629</link>
      <description>&lt;P&gt;This likely means that at least one of the variables that the datasets have in common doesn't have the same value in both datasets. You could work around that problem by renaming the variable in one of the datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table compustat_1 as
select *
from transform natural join transform2(rename=z=z2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;that way the natural join will not try to match variables &lt;EM&gt;z&lt;/EM&gt; from both datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 03:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408315#M99629</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-29T03:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408316#M99630</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/167782"&gt;@dlazer1&lt;/a&gt; this is the right time to example input data and what you expect as result.&lt;BR /&gt;"but I want it all to be in one data set" sounds like you need to rename the variables in you dataset to have them all next to each other..</description>
      <pubDate>Sun, 29 Oct 2017 04:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408316#M99630</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-10-29T04:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408318#M99631</link>
      <description>&lt;P&gt;This part is also likely incorrect:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;a.ROA-b.ROA&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 04:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408318#M99631</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-29T04:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge 2 datasets that are the same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408321#M99633</link>
      <description>&lt;P&gt;Are you sure you want to merge and not concatenate the two datasets?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data compustat_1;
 set transform transform2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the variable that is different?&amp;nbsp; Is it only one variable in one dataset? Or one variable in each dataset?&amp;nbsp; If in both does it have different names in both datasets?&amp;nbsp; If it does have the same name in both datasets then which value do you want to appear in the result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are merging do the only want observations that are in both? Or observations that are either?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are your actual key variables that uniquely identify the observations in each file?&amp;nbsp; What is the purpose of the other variables?&lt;/P&gt;
&lt;P&gt;Or do you have multiple observations per key value?&amp;nbsp; If so is it multiple observations in both input datasets? Or only in one?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 05:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-2-datasets-that-are-the-same/m-p/408321#M99633</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-29T05:44:05Z</dc:date>
    </item>
  </channel>
</rss>

