<?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 create a new binary variable based on the value of another numeric varialbe? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422091#M280874</link>
    <description>&lt;P&gt;A caution when using &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16777"&gt;@WarrenKuhfeld&lt;/a&gt;'s solution if your variable may contain missing values. Missing is always less than any given value. So if you do not want missing to actually be assigned to&amp;nbsp;0 you need to ensure that you filter your data such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not missing(Days) then Perform = Days ge 30;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that If / Then/ Else approach has the same potential flaw.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Dec 2017 19:03:28 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-12-18T19:03:28Z</dc:date>
    <item>
      <title>how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422044#M280867</link>
      <description>&lt;P&gt;I try to create a new binary variable Perform (1 or 0) based on another numeric variable Days. I am using SAS Enterprise guide 6.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

  set test;

  if Days =&amp;lt; 30 then Perform = 0;

  else if Days &amp;gt; 30 then Perform = 1;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;But the Perform only shows 0 although many observations have Days&amp;nbsp;&amp;gt; 30. I&amp;nbsp;also tried&amp;nbsp;to switch the order of the codes as follow: &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;data want;

  set test;

  if Days &amp;gt; 30 then Perform = 1;

  else if Days =&amp;lt; 30 then Perform = 0;

run;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I got the same results.&amp;nbsp;The new variable&lt;FONT face="Courier New"&gt;&amp;nbsp;Perform shows 0 for all the observations. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;Can anybody help me with this problem?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New"&gt;Any help is highly appreciated. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 16:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422044#M280867</guid>
      <dc:creator>jeniffer_jacob</dc:creator>
      <dc:date>2017-12-18T16:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422046#M280868</link>
      <description>&lt;P&gt;Can you show the output of a proc means on your data first?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=test n min max median p5 p95;
var perform;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Dec 2017 16:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422046#M280868</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-18T16:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422054#M280869</link>
      <description>&lt;P&gt;Hello Reeza:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is no Perform in the data test. Should I create this new variable first before I use it? If I should, could you show me how?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought that when I used a new variable, I created this variable automatically in the dataset want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 17:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422054#M280869</guid>
      <dc:creator>jeniffer_jacob</dc:creator>
      <dc:date>2017-12-18T17:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422056#M280870</link>
      <description>&lt;P&gt;There seems to be this widespread idea that you need to use IF and ELSE to create a binary variable.&amp;nbsp; You do not.&amp;nbsp; The result of a Boolean expression is 0 or 1.&amp;nbsp; This will do what you are trying to do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perform = Days ge 30;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;without resorting to two statements.&amp;nbsp;&amp;nbsp;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; previously noted, ensure that your values coming in really have the values that you think they do.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 17:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422056#M280870</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-12-18T17:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422057#M280871</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Try this.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;  set test;&lt;BR /&gt;Perform = 0;&lt;BR /&gt;if Days &amp;gt; 30 then Perform = 1;&lt;BR /&gt;run;</description>
      <pubDate>Mon, 18 Dec 2017 17:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422057#M280871</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2017-12-18T17:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422058#M280872</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/164846"&gt;@jeniffer_jacob&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello Reeza:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no Perform in the data test. Should I create this new variable first before I use it? If I should, could you show me how?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought that when I used a new variable, I created this variable automatically in the dataset want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry, that should have been the DAYS variable. Basically you need to check the distribution to see if the error is in your data, your code or your understanding of the data.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 17:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422058#M280872</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-18T17:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422062#M280873</link>
      <description>&lt;P&gt;It worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for all the kind replies.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 17:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422062#M280873</guid>
      <dc:creator>jeniffer_jacob</dc:creator>
      <dc:date>2017-12-18T17:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422091#M280874</link>
      <description>&lt;P&gt;A caution when using &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16777"&gt;@WarrenKuhfeld&lt;/a&gt;'s solution if your variable may contain missing values. Missing is always less than any given value. So if you do not want missing to actually be assigned to&amp;nbsp;0 you need to ensure that you filter your data such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not missing(Days) then Perform = Days ge 30;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that If / Then/ Else approach has the same potential flaw.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 19:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422091#M280874</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-18T19:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new binary variable based on the value of another numeric varialbe?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422121#M280875</link>
      <description>&lt;P&gt;A very good point about missing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2017 20:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-new-binary-variable-based-on-the-value-of/m-p/422121#M280875</guid>
      <dc:creator>jeniffer_jacob</dc:creator>
      <dc:date>2017-12-18T20:02:48Z</dc:date>
    </item>
  </channel>
</rss>

