<?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: Using If else if then to recode variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593520#M170332</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288742"&gt;@zimu94681&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Does it mean that it's not a solvable situation? SAS can't distinguish negative values from missing value?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's not what it means. It means that missing is considered less than zero. Missing is also different than -1, and missing is different than -2, and so on.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Oct 2019 19:35:36 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-10-02T19:35:36Z</dc:date>
    <item>
      <title>Using If else if then to recode variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593065#M170138</link>
      <description>&lt;P&gt;I have a dataset named&amp;nbsp;"test"&amp;nbsp;like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; A&amp;nbsp; B&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;0&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&amp;nbsp; .&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;-1&lt;/P&gt;&lt;P&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;10&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote a program to define a new variable "c"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; or b&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; c=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a&amp;lt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; and b&amp;lt;0&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; c=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;else c=.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wish to see observation 7-10, c=. (missing)&lt;/P&gt;&lt;P&gt;But using the&amp;nbsp;codes I wrote, I got all observation from 5-10, c=99 (observation 5 and 6, I want their c to be 99, but not observations&amp;nbsp;7-10)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone modify my codes and make observation 7-10 column c to missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks!!!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 15:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593065#M170138</guid>
      <dc:creator>zimu94681</dc:creator>
      <dc:date>2019-10-01T15:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using If else if then to recode variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593067#M170139</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288742"&gt;@zimu94681&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Corrected version&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data test;
input ID  A  B;
cards;
1    1  1
2    1  1
3    1  0
4    0  1
5    -1  .
6    .   -1
7    .    .
8    .    .
9    .    .
10  .    .
;

data test1;

set test;

if a&amp;gt;0 or b&amp;gt;0 then c=1;

else if .&amp;lt;a&amp;lt;0 or .&amp;lt;b&amp;lt;0 then c=99;

else c=.;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Oct 2019 15:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593067#M170139</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-10-01T15:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using If else if then to recode variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593068#M170140</link>
      <description>&lt;P&gt;Why not test for that first?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(A) and missing(B) then c=.;
else if A&amp;gt;0 or B&amp;gt;0 then C=1;
else C=99;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also what do you do when A or B is exactly zero?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 15:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593068#M170140</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-01T15:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using If else if then to recode variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593071#M170141</link>
      <description>&lt;P&gt;Unstated in the above replies is that a missing numeric is considered to be less than zero. That's why your code produces a 99 for C. Either of the replies above have code to correct for this.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 15:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593071#M170141</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-01T15:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using If else if then to recode variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593139#M170170</link>
      <description>&lt;P&gt;Does it mean that it's not a solvable situation? SAS can't distinguish negative values from missing value?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 17:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593139#M170170</guid>
      <dc:creator>zimu94681</dc:creator>
      <dc:date>2019-10-01T17:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using If else if then to recode variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593161#M170181</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288742"&gt;@zimu94681&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Does it mean that it's not a solvable situation? SAS can't distinguish negative values from missing value?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;SAS has 28 missing values. All missing values are treated as smaller than any actual number and they actually are ordered.&amp;nbsp; .Z is the largest missing value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;.Z &amp;lt; x &amp;lt; 0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 18:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593161#M170181</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-01T18:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using If else if then to recode variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593520#M170332</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288742"&gt;@zimu94681&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Does it mean that it's not a solvable situation? SAS can't distinguish negative values from missing value?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's not what it means. It means that missing is considered less than zero. Missing is also different than -1, and missing is different than -2, and so on.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 19:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-If-else-if-then-to-recode-variables/m-p/593520#M170332</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-02T19:35:36Z</dc:date>
    </item>
  </channel>
</rss>

