<?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 check if same id is present in 2 different datasets and flag them if it is same in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583196#M166003</link>
    <description>&lt;P&gt;Oh I took your sample &lt;STRONG&gt;as-is.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let us know which ones are &lt;STRONG&gt;char and num. &lt;/STRONG&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2019 14:18:22 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-08-22T14:18:22Z</dc:date>
    <item>
      <title>how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583175#M165990</link>
      <description>&lt;P&gt;I have 2 datasets one main dataset and i need to check with the other dataset and if the id is same then flag as Y.&lt;/P&gt;
&lt;P&gt;Below is the example: any help on doing in one step&lt;/P&gt;
&lt;P&gt;data WORK.main;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input ID:BEST12.;&lt;BR /&gt;datalines4;&lt;BR /&gt;111&lt;BR /&gt;134&lt;BR /&gt;122&lt;BR /&gt;221&lt;BR /&gt;232&lt;BR /&gt;198&lt;BR /&gt;908&lt;BR /&gt;762&lt;BR /&gt;212&lt;BR /&gt;2122&lt;BR /&gt;3435&lt;BR /&gt;2123&lt;BR /&gt;;;;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;second dataset&lt;/P&gt;
&lt;P&gt;data WORK.BOOK11;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input LL_1:BEST12. MM_2:BEST12.;&lt;BR /&gt;datalines4;&lt;BR /&gt;111,908&lt;BR /&gt;134,762&lt;BR /&gt;122,212&lt;BR /&gt;221,&lt;BR /&gt;232,&lt;BR /&gt;198,&lt;BR /&gt;;;;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need the final dataset like below:&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 144pt; height: 195px;" border="0" width="192" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15px; width: 44px;"&gt;ID&lt;/TD&gt;
&lt;TD style="width: 60px; height: 15px;"&gt;MM_Flag&lt;/TD&gt;
&lt;TD style="width: 54px; height: 15px;"&gt;LL_Flag&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;111&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;134&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;122&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;221&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;232&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;198&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;Y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;908&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;Y&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;N&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;762&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;Y&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;N&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;212&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;Y&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;N&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;2122&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;N&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;3435&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;N&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15px; width: 44px;"&gt;2123&lt;/TD&gt;
&lt;TD style="height: 15px; width: 60px;"&gt;N&lt;/TD&gt;
&lt;TD style="height: 15px; width: 54px;"&gt;N&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any help in how to solve this please&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 13:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583175#M165990</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-08-22T13:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583177#M165991</link>
      <description>&lt;P&gt;I think we need more detailed information from you on how the final table is created from the original data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first data set — are these LL or MM flags?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the second data set, it's not clear to me how you are using the two different columns, LL_1 and MM_2.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 13:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583177#M165991</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-22T13:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583179#M165993</link>
      <description>&lt;P&gt;In the first dataset it is named as ID and in the second there are 2 variables called LL_ and MM_ which has same id's which are on the first one. I need to merge and see if the ID is matching with LL_ then have a flag LL_fag='Y' for that id and the same with the other one.&lt;/P&gt;
&lt;P&gt;Hope this explains&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 13:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583179#M165993</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-08-22T13:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583185#M165997</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IMHO, It's better to keep Y and N rather as 1's and 0's. Always easy to crunch or play with numbers and formatting the same as characters if you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.main;
infile datalines dsd truncover;
input ID:BEST12.;
datalines4;
111
134
122
221
232
198
908
762
212
2122
3435
2123
;;;;

data WORK.BOOK11;
infile datalines dsd truncover;
input LL_1:BEST12. MM_2:BEST12.;
datalines4;
111,908
134,762
122,212
221,
232,
198,
;;;;
proc sql;
create table want as
select id, max(indexw(put(b.MM_2,best12.),put(id,best12.))&amp;gt;0) as MM_Flag,max(indexw(put(b.LL_1,best12.),put(id,best12.))&amp;gt;0) as LL_Flag
from main a,BOOK11 b
group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583185#M165997</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-22T14:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583186#M165998</link>
      <description>&lt;P&gt;Okay&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&amp;nbsp; &amp;nbsp;Just in case, if you may not want to take my opinion as still want the values as 'Y and 'N'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select id, ifc(max(indexw(put(b.MM_2,best12.),put(id,best12.))&amp;gt;0),'Y','N') as MM_Flag,ifc(max(indexw(put(b.LL_1,best12.),put(id,best12.))&amp;gt;0),'Y','N') as LL_Flag
from main a,BOOK11 b
group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583186#M165998</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-22T14:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583188#M165999</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.main;
infile datalines dsd truncover;
input ID:BEST12.;
datalines4;
111
134
122
221
232
198
908
762
212
2122
3435
2123
;;;;


data LL(keep=ll_1) MM(keep=mm_2);
infile datalines dsd truncover;
input LL_1:BEST12. MM_2:BEST12.;
if not missing(ll_1) then output LL;
if not missing(mm_2) then output mm;
datalines4;
111,908
134,762
122,212
221,
232,
198,
;;;;

proc sort data=main; by id; run;
proc sort data=ll; by ll_1; run;
proc sort data=mm; by mm_2; run;

data combine;
    merge main(in=in1) ll(in=in2 rename=(ll_1=id)) mm(in=in3 rename=(mm_2=id));
	by id;
	if in1 and in3 then mm_flag='Y';
	if in1 and in2 then ll_flag='Y';
	if ll_flag^='Y' then ll_flag='N';
	if mm_flag^='Y' then mm_flag='N';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583188#M165999</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-22T14:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583189#M166000</link>
      <description>&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;, in the long run 0s and 1s are better than Y and N.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583189#M166000</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-22T14:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583192#M166001</link>
      <description>&lt;P&gt;I get numeric formats error if i use best12.&lt;/P&gt;
&lt;P&gt;ERROR: Numeric format BEST in PUT function requires a numeric argument.&lt;BR /&gt;ERROR: Numeric format BEST in PUT function requires a numeric argument.&lt;BR /&gt;ERROR: Numeric format BEST in PUT function requires a numeric argument.&lt;BR /&gt;ERROR: Numeric format BEST in PUT function requires a numeric argument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583192#M166001</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-08-22T14:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583194#M166002</link>
      <description>&lt;P&gt;The ID variable is character variable so i cannot use best12. format&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:16:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583194#M166002</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-08-22T14:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583196#M166003</link>
      <description>&lt;P&gt;Oh I took your sample &lt;STRONG&gt;as-is.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let us know which ones are &lt;STRONG&gt;char and num. &lt;/STRONG&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583196#M166003</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-22T14:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583197#M166004</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The ID variable is character variable so i cannot use best12. format&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's unclear exactly what you are referring to via this comment.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583197#M166004</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-22T14:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583198#M166005</link>
      <description>&lt;P&gt;all vaariables are characters in these cases&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583198#M166005</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-08-22T14:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583200#M166007</link>
      <description>&lt;P&gt;all the variables i mentioned in the example are character variables&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583200#M166007</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-08-22T14:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583203#M166008</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;all the variables i mentioned in the example are character variables&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is not clear what you are referring to via this comment ... show us the part of the code you are referring to ... show us the error in your SAS log, where you provide the entire SAS log and not just the error messages.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583203#M166008</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-22T14:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583204#M166009</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sql&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; want as
&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;ifc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;indexw&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;b&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;MM_2&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;best12&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;best12&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'Y'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'N'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as MM_Flag&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;ifc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;indexw&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;b&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;LL_1&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;best12&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;best12&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'Y'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'N'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as LL_Flag
&lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; main a&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;BOOK11 b
&lt;SPAN class="token keyword"&gt;group&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;quit&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ERROR: Numeric format BEST in PUT function requires a numeric argument.&lt;BR /&gt;ERROR: Numeric format BEST in PUT function requires a numeric argument.&lt;BR /&gt;ERROR: Numeric format BEST in PUT function requires a numeric argument.&lt;BR /&gt;ERROR: Numeric format BEST in PUT function requires a numeric argument.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583204#M166009</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2019-08-22T14:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583205#M166010</link>
      <description>&lt;P&gt;So way back in &lt;A href="https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583194#M166002" target="_self"&gt;message 9&lt;/A&gt; of this thread, you replied to me, but this is not my code. So that's why I was very unclear about what you were saying.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583205#M166010</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-22T14:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583206#M166011</link>
      <description>&lt;P&gt;Okay&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&amp;nbsp; In that case all you need is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select id, ifc(max(indexw(MM_2,id)&amp;gt;0),'Y','N') as MM_Flag,ifc(max(indexw(LL_1,id)&amp;gt;0),'Y','N') as LL_Flag
from main a,BOOK11 b
group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; Methinks the OP is confused with the concept of formats from the pursuant of the format question. Anyways, it's not a concern for us.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583206#M166011</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-22T14:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if same id is present in 2 different datasets and flag them if it is same</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583452#M166096</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.main;
infile datalines dsd truncover;
input ID:BEST12.;
datalines4;
111
134
122
221
232
198
908
762
212
2122
3435
2123
;;;;

data WORK.BOOK11;
infile datalines dsd truncover;
input LL_1:BEST12. MM_2:BEST12.;
datalines4;
111,908
134,762
122,212
221,
232,
198,
;;;;

data want;
 if _n_=1 then do;
   if 0 then set book11;
   declare hash L(dataset:'book11(keep=LL_1 where=(LL_1 is not missing))');
   L.definekey('LL_1');
   L.definedone();
   declare hash M(dataset:'book11(keep=MM_2 where=(MM_2 is not missing))');
   M.definekey('MM_2');
   M.definedone();
 end;
set main;
if L.check(key:id)=0 then LL_Flag='Y';else LL_Flag='N';
if M.check(key:id)=0 then MM_Flag='Y';else MM_Flag='N';
drop LL_1 MM_2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Aug 2019 12:47:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-check-if-same-id-is-present-in-2-different-datasets-and/m-p/583452#M166096</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-08-23T12:47:36Z</dc:date>
    </item>
  </channel>
</rss>

