<?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: Recoding variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388355#M93136</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151035"&gt;@NadiaK&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to recode a variable containing numbers in decimal form. Whatever number is in that variable, I would like it to be coded as 1 and the missing values to be coded as 0. Does anyone have a quick easy solution?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The MISSING() function will return 1 (true) if the value is missing and 0 (false) if not. So you just want&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x = not missing(x);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 16 Aug 2017 01:27:07 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-08-16T01:27:07Z</dc:date>
    <item>
      <title>Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388332#M93122</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to recode a variable containing numbers in decimal form. Whatever number is in that variable, I would like it to be coded as 1 and the missing values to be coded as 0. Does anyone have a quick easy solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 22:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388332#M93122</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2017-08-15T22:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388334#M93124</link>
      <description>&lt;P&gt;Can you post sample data to illustrate what you're trying to accomplish?&lt;/P&gt;
&lt;P&gt;Include what you have and what you need.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 22:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388334#M93124</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-15T22:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388340#M93127</link>
      <description>&lt;P&gt;How about:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;varname = (varname ne . );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In light of subsequent comments ... this approach can handle special missing values with just a slight change:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;varname = (varname&amp;nbsp;&amp;gt; .z) ;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 02:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388340#M93127</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-16T02:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388341#M93128</link>
      <description>&lt;P&gt;Assuming the present variable is called VAR - do you mean:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt; &amp;nbsp;if missing(var) then code=0; else code=1;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 22:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388341#M93128</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-15T22:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388346#M93130</link>
      <description>&lt;P&gt;x = n(x);&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 00:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388346#M93130</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-08-16T00:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388347#M93131</link>
      <description>That's a good idea. Let me try it out!&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Aug 2017 00:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388347#M93131</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2017-08-16T00:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388348#M93132</link>
      <description>Yes!&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Aug 2017 00:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388348#M93132</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2017-08-16T00:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388349#M93133</link>
      <description>I am not sure I understand this. Bear with me, I'm super new at this stuff!&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":relieved_face:"&gt;😌&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Aug 2017 00:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388349#M93133</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2017-08-16T00:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388351#M93134</link>
      <description>&lt;P&gt;The n function returns the number of nonmissing arguments. &amp;nbsp;There are 28 types of missing values, so direct comparisons to '.' might work for most data sets, but that does not provide a general solution. &amp;nbsp;Solutions involving the N and NMISS functions work for any type of missing. &amp;nbsp;Also, one does not need an IF/ELSE sequence when the goal is to create a single variable. &amp;nbsp;If the result is Boolean, just assign the result 0 or 1 to a value. &amp;nbsp;X = (X ne .); is a perfectly fine assignment statement that avoids IF/ELSE (although again, it does not provide a general solution). &amp;nbsp;Also see IFN &amp;nbsp;and IFC. &amp;nbsp;This is harder than it needs to be for your problem, but it again avoids using two statements where one works. &amp;nbsp;x = ifn(n(x), 1, 0);&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 00:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388351#M93134</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-08-16T00:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388354#M93135</link>
      <description>Wow! Thanks so much!!&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Aug 2017 00:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388354#M93135</guid>
      <dc:creator>NadiaK</dc:creator>
      <dc:date>2017-08-16T00:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388355#M93136</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151035"&gt;@NadiaK&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to recode a variable containing numbers in decimal form. Whatever number is in that variable, I would like it to be coded as 1 and the missing values to be coded as 0. Does anyone have a quick easy solution?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The MISSING() function will return 1 (true) if the value is missing and 0 (false) if not. So you just want&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x = not missing(x);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Aug 2017 01:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-variables/m-p/388355#M93136</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-16T01:27:07Z</dc:date>
    </item>
  </channel>
</rss>

