<?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: flagging based on a different datset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/440770#M110185</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dataflagged;
  if _N_ = 1 then do;  
    declare hash CHK(dataset: "data2");
    CHK.definekey("ID");
    CHK.definedone();
  end;
  set data1;
  flag = CHK.check() = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Feb 2018 04:50:23 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-02-28T04:50:23Z</dc:date>
    <item>
      <title>flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/440730#M110166</link>
      <description>&lt;P&gt;I have 2 datasets, data1 is repeated and data2 is not. I would like to add a flag=1 in data1 if ID is in data2 and flag=0 if not. I have the following code but it is marking all as flag=0, can you please help me troubleshoot?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;data dataflagged;&lt;BR /&gt;&amp;nbsp; if _N_ = 1 then do; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash CHK(dataset: "data2", multidata:'y');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHK.definekey("ID");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHK.definedone();&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; set data1;&lt;BR /&gt;&amp;nbsp; flag = (CHK.check()=1);&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 02:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/440730#M110166</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-28T02:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/440742#M110172</link>
      <description>&lt;P&gt;If found,&amp;nbsp;&lt;SPAN&gt;CHK.check()=0.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 03:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/440742#M110172</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-02-28T03:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/440770#M110185</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dataflagged;
  if _N_ = 1 then do;  
    declare hash CHK(dataset: "data2");
    CHK.definekey("ID");
    CHK.definedone();
  end;
  set data1;
  flag = CHK.check() = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 04:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/440770#M110185</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-28T04:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441051#M110278</link>
      <description>It is marking all flags as 0 for some reason. The ID variable are numbers formatted as 8.characters. in both datasets. I am just eyeballing and I see a lot of matching IDs, so I cant figure out why the flag isnt working..</description>
      <pubDate>Wed, 28 Feb 2018 22:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441051#M110278</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-28T22:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441052#M110279</link>
      <description>&lt;P&gt;Are they really equal in both datasets, or just equal once formatted?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 22:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441052#M110279</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-28T22:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441056#M110280</link>
      <description>Not sure I know the difference but they are equal in values before and after formatting.</description>
      <pubDate>Wed, 28 Feb 2018 22:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441056#M110280</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-28T22:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441071#M110283</link>
      <description>&lt;P&gt;It *should* work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1;
do id = 1,1,2,7,9; output; end;
format id 8.;
run;

data data2;
do id = 1,7; output; end;
format id 8.;
run;

data dataflagged;
  if _N_ = 1 then do;  
    declare hash CHK(dataset: "data2");
    CHK.definekey("ID");
    CHK.definedone();
  end;
  set data1;
  flag = CHK.check() = 0;
run;

proc print noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                        id    flag

                                         1      1
                                         1      1
                                         2      0
                                         7      1
                                         9      0
&lt;/PRE&gt;
&lt;P&gt;Post the actual code you are using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 23:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441071#M110283</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-28T23:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441962#M110549</link>
      <description>it seems the ID needs to be numeric for it to work. ID as character did not work for me.</description>
      <pubDate>Fri, 02 Mar 2018 23:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/441962#M110549</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-03-02T23:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: flagging based on a different datset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/442020#M110572</link>
      <description>&lt;P&gt;This works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1;
do id = "1","1","2","7","9"; output; end;
run;

data data2;
do id = "1","7"; output; end;
run;

data dataflagged;
  if _N_ = 1 then do;  
    declare hash CHK(dataset: "data2");
    CHK.definekey("ID");
    CHK.definedone();
  end;
  set data1;
  flag = CHK.check() = 0;
run;

proc print noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                                       id    flag

                                                       1       1
                                                       1       1
                                                       2       0
                                                       7       1
                                                       9       0
&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Mar 2018 04:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/flagging-based-on-a-different-datset/m-p/442020#M110572</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-03T04:47:48Z</dc:date>
    </item>
  </channel>
</rss>

