<?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: merging in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565923#M158959</link>
    <description>Post your code and log.&lt;BR /&gt;</description>
    <pubDate>Thu, 13 Jun 2019 16:49:23 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-06-13T16:49:23Z</dc:date>
    <item>
      <title>merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565878#M158933</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;I have 2 data sets set like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;id name age sex&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data set 1:&lt;/P&gt;&lt;P&gt;1 sima 23 f&lt;/P&gt;&lt;P&gt;2 shyam 34 m&lt;/P&gt;&lt;P&gt;3 ana 35 f&lt;/P&gt;&lt;P&gt;4 jacob 26 m&lt;/P&gt;&lt;P&gt;5 chris 34 m&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data set 2:&lt;/P&gt;&lt;P&gt;id&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;how can i have output like this?&lt;/P&gt;&lt;P&gt;1 sima 23 f&lt;/P&gt;&lt;P&gt;3 ana 35 f&lt;/P&gt;&lt;P&gt;5 chris 34 m&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 15:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565878#M158933</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-06-13T15:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565892#M158939</link>
      <description>&lt;P&gt;There are several ways.&lt;/P&gt;
&lt;P&gt;Data step merge would require sorting the data on the matching variable (id) and use of a BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sort data=set1;
  by id;
run;

proc sort data=set2;
  by id;
run;

/* merge*/
data want;
   merge set1 (in=in1) 
         set2 (in=in2)
   ;
   by id;
   if in1 and in2;
run;&lt;/PRE&gt;
&lt;P&gt;The IN= data set option creates temporary variables that indicate if the current record has values from that data set, 1 when true and 0 when false.&lt;/P&gt;
&lt;P&gt;So if both are true you have the matching values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or proc sql:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table want as
   select b.* 
   from set2 as a
        left join
        set1 as b
        on a.id=b.id
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;If you have repeats of the ID in one or both data sets then more consideration may be needed.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 15:30:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565892#M158939</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-13T15:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565905#M158944</link>
      <description>&lt;P&gt;I used the first code you sen to me; the log says this;&lt;/P&gt;&lt;P&gt;NOTE: There were 9346 observations read from the data set WORK.CHECKING_A.&lt;BR /&gt;NOTE: There were 2576 observations read from the data set WORK.CHRIS_CHECKING_A.&lt;BR /&gt;NOTE: The data set WORK.WANT has 0 observations and 58 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;And the result is only name of the variables with no values&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 16:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565905#M158944</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-06-13T16:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565912#M158949</link>
      <description>This means your data isn't matching at all for some reason, for example the cases differ, ie VARA is not the same as varA. This is a data problem though, not a code problem.</description>
      <pubDate>Thu, 13 Jun 2019 16:21:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565912#M158949</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T16:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565916#M158953</link>
      <description>Do all of the variables name match in both datasets even one of the data set has only ids?&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Jun 2019 16:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565916#M158953</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-06-13T16:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565923#M158959</link>
      <description>Post your code and log.&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Jun 2019 16:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565923#M158959</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T16:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565931#M158965</link>
      <description>data checking_A;&lt;BR /&gt;set checking;&lt;BR /&gt;ID=put(event_id, best11.);/*converting numeric CL_eventid to character EventID as it is in the other dataset*/&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=checking_a;&lt;BR /&gt;by ID;&lt;BR /&gt;run;&lt;BR /&gt;data chris_checking_A(keep=EventID);&lt;BR /&gt;length EventID $11.;&lt;BR /&gt;set chris_checking;&lt;BR /&gt;where CL_Facility_location="MIL-01";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data chris_checking_B;&lt;BR /&gt;set chris_checking_A;&lt;BR /&gt;rename eventid=id;&lt;BR /&gt;label eventid=id;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=chris_checking_B;&lt;BR /&gt;by ID;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table CheckingAA as&lt;BR /&gt;select id.*&lt;BR /&gt;from checking_A as a&lt;BR /&gt;left join&lt;BR /&gt;chris_checking_B as b&lt;BR /&gt;on a.id=b.id&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;547 proc sql;&lt;BR /&gt;548 create table CheckingAA as&lt;BR /&gt;549 select id.*&lt;BR /&gt;550 from checking_A as a&lt;BR /&gt;551 left join&lt;BR /&gt;552 chris_checking_B as b&lt;BR /&gt;553 on a.id=b.id&lt;BR /&gt;554 ;&lt;BR /&gt;ERROR: Could not expand id.*, correlation name not found.&lt;BR /&gt;ERROR: Ambiguous reference, column id is in more than one table.&lt;BR /&gt;555 quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;&lt;BR /&gt;cpu time 0.03 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Jun 2019 17:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565931#M158965</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-06-13T17:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565943#M158972</link>
      <description>ID.* is not a table, fix that error and that step will run but no idea if that's the step with the mistake because you didn't include he full log. &lt;BR /&gt;&lt;BR /&gt;The SQL syntax is tableAlias.* or tableName.* to select all variables. You have no tableAlias or tableName set as *. Replace that ID with either A or B depending on which data set you want data from. Or remove ID if you want from both fields, but if you have have variables with the same name that won't work either.</description>
      <pubDate>Thu, 13 Jun 2019 17:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/565943#M158972</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T17:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging/m-p/566164#M159070</link>
      <description>&lt;PRE&gt;proc sql;
   create table want as
   select * 
   from set1 &lt;BR /&gt;   where id in (select id from set2)
   ;
quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jun 2019 12:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging/m-p/566164#M159070</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-06-14T12:57:30Z</dc:date>
    </item>
  </channel>
</rss>

