<?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 binary variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506473#M135791</link>
    <description>&lt;P&gt;if you need to search character string for multiple strings then you can use multiple INDEX() or FIND() or else you can use single PRXMATCH() with multiple substring values listed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;  
  if index(lowcase(charvar),'this') &amp;gt; 0 or 
       index(lowcase(charvar),'that') &amp;gt; 0 or
       index(lowcase(charvar),'other') &amp;gt; 0 then found = 1;
    else found=0;
run;

data want;
set have;
    if prxmatch("m/this|that|other/oi",charvar) &amp;gt; 0 then found=1;
    else found=0;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Oct 2018 15:01:55 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-10-22T15:01:55Z</dc:date>
    <item>
      <title>How to create a binary variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506465#M135786</link>
      <description>&lt;P&gt;I need help creating a new binary variable from an existing&amp;nbsp;data set. The variable name is deathcauses&amp;nbsp;(Cerebral Vascular Disease Coronary Heart Disease, Cancer, Other, or Unknown). I want to create a new binary variable of 0 = heart-related causes and 1 = other causes.&amp;nbsp;The data&amp;nbsp;set is FraminghamD.&amp;nbsp;Please, I need help with the correct SAS code. Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 14:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506465#M135786</guid>
      <dc:creator>oniume</dc:creator>
      <dc:date>2018-10-22T14:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a binary variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506467#M135788</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if deathcauses in ('Vascular Disease','Coronary Heart Disease') then binary_variable=1;
else binary_variable=0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Oct 2018 14:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506467#M135788</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-22T14:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a binary variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506468#M135789</link>
      <description>&lt;P&gt;A binary variable can be created using IF/THEN statements. However, without knowing your variable name it's hard to suggest the 'correct' SAS code. &lt;BR /&gt;&lt;BR /&gt;An example would be the following, which creates a binary variable that shows if the sex of a person is male or female.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set sashelp.class;
if sex='F' then Female=1;
else Female=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/241860"&gt;@oniume&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I need help creating a new binary variable from an existing&amp;nbsp;data set. The variable name is deathcauses&amp;nbsp;(Cerebral Vascular Disease Coronary Heart Disease, Cancer, Other, or Unknown). I want to create a new binary variable of 0 = heart-related causes and 1 = other causes.&amp;nbsp;The data&amp;nbsp;set is FraminghamD.&amp;nbsp;Please, I need help with the correct SAS code. Thank you&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 14:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506468#M135789</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-22T14:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a binary variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506473#M135791</link>
      <description>&lt;P&gt;if you need to search character string for multiple strings then you can use multiple INDEX() or FIND() or else you can use single PRXMATCH() with multiple substring values listed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;  
  if index(lowcase(charvar),'this') &amp;gt; 0 or 
       index(lowcase(charvar),'that') &amp;gt; 0 or
       index(lowcase(charvar),'other') &amp;gt; 0 then found = 1;
    else found=0;
run;

data want;
set have;
    if prxmatch("m/this|that|other/oi",charvar) &amp;gt; 0 then found=1;
    else found=0;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Oct 2018 15:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506473#M135791</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-22T15:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a binary variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506474#M135792</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/241860"&gt;@oniume&lt;/a&gt;&amp;nbsp;Welcome to the SAS forum and Good morning. Please post sample of data that you HAVE and the required output you WANT than just sentences for us to work with in the future.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 15:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-binary-variable/m-p/506474#M135792</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-22T15:03:14Z</dc:date>
    </item>
  </channel>
</rss>

