<?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: replacing values with yes or no in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746685#M234265</link>
    <description>&lt;P&gt;You may want to test on policy_no:.&amp;nbsp; I assume you will be getting data from elsewhere, so you probably need to handle the case where no reply is given.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input policy_no Alcohol &amp;amp; $80.;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;if policy_no = . then alcohol = 'unknown';&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;else if policy_no = 1 then alcohol = 'no';&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;else alcohol = 'yes';&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;
datalines;
1 I don't drink alcohol
2 Less than 5 drinks
3 Between 5 and 21 drinks
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Jun 2021 08:26:06 GMT</pubDate>
    <dc:creator>DavePrinsloo</dc:creator>
    <dc:date>2021-06-09T08:26:06Z</dc:date>
    <item>
      <title>replacing values with yes or no</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746680#M234261</link>
      <description>&lt;P&gt;Hi i need help in replacing the values from below code with yes or no....if the value =&lt;STRONG&gt;&amp;nbsp;I don't drink alcohol&amp;nbsp;&lt;/STRONG&gt;then replace it with &lt;STRONG&gt;no,&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;otherwise replace it with &lt;STRONG&gt;yes..&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input policy_no Alcohol &amp;amp; $80.;
datalines;
1 I don't drink alcohol
2 Less than 5 drinks
3 Between 5 and 21 drinks
;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jun 2021 07:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746680#M234261</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2021-06-09T07:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: replacing values with yes or no</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746682#M234262</link>
      <description>&lt;P&gt;Replacing it is a bad idea.&amp;nbsp; You actually lose information.&amp;nbsp; Instead, create a new variable.&amp;nbsp; One way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   length alcohol_yn $ 3;
   if alcohol = "I don't drink alcohol" then alcohol_yn = "no";
   else if alcohol &amp;gt; " " then alcohol_yn = "yes";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice that the new variable will be left blank if the original variable is blank.&amp;nbsp; Also note that comparisons require an exact match ... spelling, capitalization, punctuation.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 07:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746682#M234262</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-06-09T07:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: replacing values with yes or no</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746685#M234265</link>
      <description>&lt;P&gt;You may want to test on policy_no:.&amp;nbsp; I assume you will be getting data from elsewhere, so you probably need to handle the case where no reply is given.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input policy_no Alcohol &amp;amp; $80.;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;if policy_no = . then alcohol = 'unknown';&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;else if policy_no = 1 then alcohol = 'no';&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;else alcohol = 'yes';&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;
datalines;
1 I don't drink alcohol
2 Less than 5 drinks
3 Between 5 and 21 drinks
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 08:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746685#M234265</guid>
      <dc:creator>DavePrinsloo</dc:creator>
      <dc:date>2021-06-09T08:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: replacing values with yes or no</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746696#M234269</link>
      <description>&lt;P&gt;If you wan a new variable, using an informat seems to be a good idea:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	invalue $alcoIn (upcase)
		' ' = ' '
		"I DON'T DRINK ALCOHOL" = 'no'
		other = 'yes'
	;	
run;

data want;
	set have;
	length alcohol_yn $3;
	
	alcohol_yn = input(alcohol, $alcoIn.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jun 2021 09:44:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-values-with-yes-or-no/m-p/746696#M234269</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-06-09T09:44:28Z</dc:date>
    </item>
  </channel>
</rss>

