<?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: selecting common observation based on all variable names with source dataset name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366463#M87186</link>
    <description>&lt;P&gt;I want to show duplicate records with their source_name&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2017 09:56:00 GMT</pubDate>
    <dc:creator>atul_desh</dc:creator>
    <dc:date>2017-06-13T09:56:00Z</dc:date>
    <item>
      <title>selecting common observation based on all variable names with source dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366457#M87182</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ds1;&lt;/P&gt;&lt;P&gt;input var1 var2 var3 var4 var5;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 2 3 4 5&lt;/P&gt;&lt;P&gt;6 7 8 9 10&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ds2;&lt;/P&gt;&lt;P&gt;input var1 var2 var3 var4 var5;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;11 12 13 14 15&lt;/P&gt;&lt;P&gt;1 2 3 4 5&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want [[common observation from ds1 &amp;amp; ds2, with their source table] ] should be look like :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var1 var2 var3 var4 var5 DS_Name&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; ds1&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; ds2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 09:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366457#M87182</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-06-13T09:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: selecting common observation based on all variable names with source dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366460#M87184</link>
      <description>&lt;P&gt;What is the purpose of DS_NAME and having the same observation twice, but with a different DS_NAME, that you already know, since you provided the datasets yourself?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 09:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366460#M87184</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-13T09:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: selecting common observation based on all variable names with source dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366463#M87186</link>
      <description>&lt;P&gt;I want to show duplicate records with their source_name&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 09:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366463#M87186</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-06-13T09:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: selecting common observation based on all variable names with source dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366468#M87190</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds1;
input var1 var2 var3 var4 var5;
datalines;
1 2 3 4 5
6 7 8 9 10
;

data ds2;
input var1 var2 var3 var4 var5;
datalines;
11 12 13 14 15
1 2 3 4 5
;

proc sort data = ds1;
	by var1-var5;
run;

proc sort data = ds2;
	by var1-var5;
run;

%let d1 = ds1;
%let d2 = ds2;

data want;
	merge &amp;amp;d1(in=in1) &amp;amp;d2(in=in2);
	by var1-var5;
	if in1 &amp;amp; in2 then do;
		DS_NAME = "&amp;amp;d1"; output;
		DS_NAME = "&amp;amp;d2"; output;
	end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jun 2017 10:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/366468#M87190</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-13T10:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: selecting common observation based on all variable names with source dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/368271#M87812</link>
      <description>&lt;P&gt;If I want duplicate based on var1-var4, then var5 is coming from second dataset only.. is there any way to get correct value :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output is coming like(var5 is coming from ds2 in both the dataset,which should 6 in first observation) :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Obs var1 var2 var3 var4 var5 DS_NAME 1 2 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;ds1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;ds2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;data ds1;&lt;BR /&gt;input var1 var2 var3 var4 var5;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2 3 4 6&lt;BR /&gt;6 7 8 9 10&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data ds2;&lt;BR /&gt;input var1 var2 var3 var4 var5;&lt;BR /&gt;datalines;&lt;BR /&gt;11 12 13 14 15&lt;BR /&gt;1 2 3 4 7&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sort data = ds1;&lt;BR /&gt;by var1-var4;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data = ds2;&lt;BR /&gt;by var1-var4;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%let d1 = ds1;&lt;BR /&gt;%let d2 = ds2;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;merge &amp;amp;d1(in=in1) &amp;amp;d2(in=in2);&lt;BR /&gt;by var1-var4;&lt;BR /&gt;if in1 &amp;amp; in2 then do;&lt;BR /&gt;DS_NAME = "&amp;amp;d1"; output;&lt;BR /&gt;DS_NAME = "&amp;amp;d2"; output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=want;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-common-observation-based-on-all-variable-names-with/m-p/368271#M87812</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-06-19T12:28:21Z</dc:date>
    </item>
  </channel>
</rss>

