<?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: sas if else then not processing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270754#M55158</link>
    <description>&lt;P&gt;Thank you very much. Though I didn't get any warnings (I just got blanks for each observation), I used the original variable name and everything worked! Thank you for the very helpful observation; conceptually this is useful going forward for me.&lt;/P&gt;</description>
    <pubDate>Mon, 16 May 2016 18:41:51 GMT</pubDate>
    <dc:creator>blakezen</dc:creator>
    <dc:date>2016-05-16T18:41:51Z</dc:date>
    <item>
      <title>sas if else then not processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270741#M55152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having an impasse with &lt;STRONG&gt;if then else if&lt;/STRONG&gt; statement options in sas. In brief:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data file 1 (&lt;/STRONG&gt;keep= var1 var2 var3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG&gt;rename &lt;/STRONG&gt;abc= var1 def=var2 ghi=var3;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set &lt;/STRONG&gt;libref.file1 (where(var 4 NE .));&lt;/P&gt;&lt;P&gt;/*so far no problems with the above */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if&lt;/STRONG&gt; 0&amp;lt;= var2 &amp;lt; 1 &lt;STRONG&gt;then&lt;/STRONG&gt; var3="100%";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;else if&lt;/STRONG&gt; 1 &amp;lt;= var2 &amp;lt;2 &lt;STRONG&gt;then &lt;/STRONG&gt;var3="110%";&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else &lt;/STRONG&gt;var3 = "110-120%"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final output is fine for all variables except for var3, which is really messed up. In fact, &lt;STRONG&gt;var3&lt;/STRONG&gt; is set to "110-" for every single observation. What am I doing wrong here and what is the matter with my syntax structure?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your time on this!&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 17:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270741#M55152</guid>
      <dc:creator>blakezen</dc:creator>
      <dc:date>2016-05-16T17:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else then not processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270745#M55153</link>
      <description>&lt;P&gt;SAS determines the length of a variable by the first use of it, unless you specify it. So it sees the first "110%" and assumes you want the var3 variable to be four characters long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Resolve this by using a LENGTH statement (&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000218807.htm" target="_self"&gt;reference&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;LENGTH var3 $8;&lt;/PRE&gt;&lt;P&gt;Include this before your IF statement.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 18:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270745#M55153</guid>
      <dc:creator>paulkaefer</dc:creator>
      <dc:date>2016-05-16T18:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else then not processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270748#M55154</link>
      <description>&lt;P&gt;Thank you! This resolved the length issue. However, I'm still not seeing anything for var3. Now, instead of the "110-" that I was seeing earlier for &lt;U&gt;every single row&lt;/U&gt;, I am now seeing blank in var 3, for every single row. What is wrong with the syntax of my if statement. Is SAS not seeing the ranges conditiones?&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 18:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270748#M55154</guid>
      <dc:creator>blakezen</dc:creator>
      <dc:date>2016-05-16T18:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else then not processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270749#M55155</link>
      <description>&lt;P&gt;For one, I'm assuming there shouldn't be a space between var4 in your WHERE statement or between file and 1 in the top line. There should also be a semicolon after the ELSE statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It wouldn't hurt to put parentheses () around the expressions, though it should work without them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What does the var2 variable look like? Are the values all positive numbers? Are they numeric or character values?&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 18:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270749#M55155</guid>
      <dc:creator>paulkaefer</dc:creator>
      <dc:date>2016-05-16T18:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else then not processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270752#M55156</link>
      <description>Thanks for your reply. You're right no spaces and there is a semicolon after the else statement. Sorry about not having that clear from the beginning.&lt;BR /&gt;&lt;BR /&gt;var 2 is a numeric character with length 8. However it has many decimal places to 10 sig digits, i.e 1.0134568920 format for each observation.</description>
      <pubDate>Mon, 16 May 2016 18:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270752#M55156</guid>
      <dc:creator>blakezen</dc:creator>
      <dc:date>2016-05-16T18:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else then not processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270753#M55157</link>
      <description>&lt;P&gt;With regard to getting "110-120%" every time, the problem is with the RENAME statement.&amp;nbsp; As a standalone statement, RENAME applies when all the processing is done and SAS is ready to output observations.&amp;nbsp; You would have to use the original variable name (GHI) in your IF/THEN statements instead of VAR3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There should at least be some sort of warning in your log about the rename not being possible.&amp;nbsp; Your IF/THEN statements create VAR3, and your RENAME statement then attempts to rename GHI to an existing name.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 18:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270753#M55157</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-16T18:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else then not processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270754#M55158</link>
      <description>&lt;P&gt;Thank you very much. Though I didn't get any warnings (I just got blanks for each observation), I used the original variable name and everything worked! Thank you for the very helpful observation; conceptually this is useful going forward for me.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 18:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/270754#M55158</guid>
      <dc:creator>blakezen</dc:creator>
      <dc:date>2016-05-16T18:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: sas if else then not processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/275700#M55159</link>
      <description>&lt;P&gt;Moved post since this is a programming issue, not a community one.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 15:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-if-else-then-not-processing/m-p/275700#M55159</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-06-07T15:04:11Z</dc:date>
    </item>
  </channel>
</rss>

