<?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: Put the dummy variable equal to one if the value is equal to a variable in another dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225225#M53909</link>
    <description>&lt;P&gt;If you don't have duplicates you can use a merge and check for matches.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have duplicates you can remove them and then use a merge and check for matches.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could use an inline query with a CASE statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CASE WHEN (SELECT A.NAME FROM HAVE AS _X WHERE A.NAME=_X.NAME) IS NOT NULL THEN 1&lt;BR /&gt;ELSE 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Sep 2015 20:12:02 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-09-11T20:12:02Z</dc:date>
    <item>
      <title>Put the dummy variable equal to one if the value is equal to a variable in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225219#M53908</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because I could not find my question amng the latest ones, so I send it again. If you find it somewhere else as well, I apologize for that.&lt;/P&gt;
&lt;P&gt;I use the following code to create a subset when the value of a variable is equal&amp;nbsp;to a variable in another dataset.&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as select *&lt;/P&gt;
&lt;P&gt;from have1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where id in(select id from have2); quit;&lt;/P&gt;
&lt;P&gt;However, I don't want to create a subset, but I want to say id_dummy=1 if id is in have2.&lt;/P&gt;
&lt;P&gt;I appreciate any suggestion.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 19:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225219#M53908</guid>
      <dc:creator>m1986MM</dc:creator>
      <dc:date>2015-09-11T19:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Put the dummy variable equal to one if the value is equal to a variable in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225225#M53909</link>
      <description>&lt;P&gt;If you don't have duplicates you can use a merge and check for matches.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have duplicates you can remove them and then use a merge and check for matches.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could use an inline query with a CASE statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CASE WHEN (SELECT A.NAME FROM HAVE AS _X WHERE A.NAME=_X.NAME) IS NOT NULL THEN 1&lt;BR /&gt;ELSE 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 20:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225225#M53909</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-09-11T20:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Put the dummy variable equal to one if the value is equal to a variable in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225226#M53910</link>
      <description>You're previous question FYI &lt;A href="https://communities.sas.com/t5/SAS-Procedures/where-statement-when-a-variable-equals-another-variable-in/m-p/210795#M52107" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/where-statement-when-a-variable-equals-another-variable-in/m-p/210795#M52107&lt;/A&gt;</description>
      <pubDate>Fri, 11 Sep 2015 20:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225226#M53910</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-09-11T20:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Put the dummy variable equal to one if the value is equal to a variable in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225227#M53911</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a;&lt;BR /&gt;input id;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;data b;&lt;BR /&gt;input id;&lt;BR /&gt;datalines;&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select aa.*,case when aa.id=bb.id then 1 else 0 end as id_dummy from a aa left join b bb&lt;BR /&gt;on aa.id=bb.id;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 20:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Put-the-dummy-variable-equal-to-one-if-the-value-is-equal-to-a/m-p/225227#M53911</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-09-11T20:15:04Z</dc:date>
    </item>
  </channel>
</rss>

