<?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: Recode a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290745#M60195</link>
    <description>&lt;P&gt;I'm going to guess that you tried something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if var=1 then var='yes';&lt;/P&gt;
&lt;P&gt;This will not work because the variable VAR is numeric and can not hold character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To add to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS﻿&lt;/a&gt;'s suggestion: Formats are very flexible. You could have multiple formats that assign different values to 1/0 and use as needed. Such as True/False&amp;nbsp; Answered/Not Answered. You could even provide more information such as "Has insurance"/"Does not have insurance", without adding any variable just using a different format for use in a procedure.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Aug 2016 15:40:44 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-08-10T15:40:44Z</dc:date>
    <item>
      <title>Recode a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290701#M60175</link>
      <description>&lt;P&gt;hey, iam new to sas , recently stuck to a problem.&lt;/P&gt;
&lt;P&gt;i am trying to convert 0 to NO and 1 to YES for a variable but get fails every time &amp;nbsp;. if plzz can anyone help me out , Thankyou.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 13:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290701#M60175</guid>
      <dc:creator>Bipingaud</dc:creator>
      <dc:date>2016-08-10T13:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Recode a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290703#M60176</link>
      <description>&lt;P&gt;Ideally you should post what you've tried so we can let you know where your having issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is should be a straightforward if then.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If var=0 the new_var='Yes';&lt;/P&gt;
&lt;P&gt;else if var=1 then new_var='No';&lt;/P&gt;
&lt;P&gt;else new_var='Other';&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 13:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290703#M60176</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-10T13:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: Recode a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290704#M60177</link>
      <description>&lt;P&gt;The easiest way is to leave the original data alone but use a SAS format to associate 0-&amp;gt;"NO" and 1-&amp;gt;"YES". See the article&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2016/08/08/sas-formats-bin-numerical-variables.html" target="_self"&gt;"Use SAS formats to bin variables"&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input Answer @@;
datalines;
0 0 1 1 1 0 1 0 1
;

proc format;
value YesNo  
      0 = "No"
      1 = "Yes";
run;

proc freq data=Have;
format Answer YesNo.;  /* assign YesNo format */
tables Answer;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 13:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290704#M60177</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-08-10T13:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Recode a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290745#M60195</link>
      <description>&lt;P&gt;I'm going to guess that you tried something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if var=1 then var='yes';&lt;/P&gt;
&lt;P&gt;This will not work because the variable VAR is numeric and can not hold character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To add to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS﻿&lt;/a&gt;'s suggestion: Formats are very flexible. You could have multiple formats that assign different values to 1/0 and use as needed. Such as True/False&amp;nbsp; Answered/Not Answered. You could even provide more information such as "Has insurance"/"Does not have insurance", without adding any variable just using a different format for use in a procedure.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 15:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recode-a-variable/m-p/290745#M60195</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-10T15:40:44Z</dc:date>
    </item>
  </channel>
</rss>

