<?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: In SAS IF is No then process in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303437#M64457</link>
    <description>&lt;P&gt;dear reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use both internet = No and Internet=Yes and if No then consider&amp;nbsp;internet_cost=0 and if yes then consider&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; Internet&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Yes'&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; INTERNET_COST &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;InternetDays&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4.95&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;9.95&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but if internet&amp;nbsp;=NO then Internet_cost=0 .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so the code would be below , plz advise , and also how to add $ sign in the column result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;Data&lt;/SPAN&gt; Format2&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
&lt;SPAN class="token keyword"&gt;SET&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;FORMAT&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;BR /&gt;if Internet=No then Internet_Cost = 0
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; Internet&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Yes'&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; INTERNET_COST &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;InternetDays&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4.95&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;9.95&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;* STORE RESULTS IN VARIABLE;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="token comment"&gt;*PRINT RESULTS TO WINDOW FOR DISPLAY;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;print&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;format2&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 09 Oct 2016 08:12:21 GMT</pubDate>
    <dc:creator>azee007</dc:creator>
    <dc:date>2016-10-09T08:12:21Z</dc:date>
    <item>
      <title>In SAS IF is No then process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303428#M64453</link>
      <description>&lt;P&gt;I am trying to use two variable : internet = Yes or No , Number of days internet used=number value. If yes then calculate activation charges 10$ and each day internet charges $5. I am not able to get results&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data format;&lt;BR /&gt;If Internet = 'No' then Do;&lt;BR /&gt;if Internet= 'Yes' then (InternetDays*4.95)+9.95;&lt;BR /&gt;input IRGA =;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=format;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 06:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303428#M64453</guid>
      <dc:creator>azee007</dc:creator>
      <dc:date>2016-10-09T06:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS IF is No then process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303432#M64455</link>
      <description>&lt;P&gt;1. You need. SET statement so you have an input dataset to process.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Input is used to read files. That's not applicable in this code. Not sure what you're trying to do with that line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. You're doing a calculation but not saving it to a variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All your mistakes are basic SAS programming skills. SAS offers the first programming course for free via an ecourse. I highly recommend you complete the course. There's also an abundance of videos on basic task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/training/tutorial/" target="_blank"&gt;http://support.sas.com/training/tutorial/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Format2; *USE A NEW DATASET NAME TO NOT OVERWRITE PREV DATA SET. THIS HELPS AVOID ERRORS;

SET FORMAT; * ASSIGN INPUT DATA SET;

if Internet= 'Yes' then INTERNET_COST = (InternetDays*4.95)+9.95; * STORE RESULTS IN VARIABLE;

run;

*PRINT RESULTS TO WINDOW FOR DISPLAY;
proc print data=format2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Oct 2016 06:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303432#M64455</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-09T06:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS IF is No then process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303437#M64457</link>
      <description>&lt;P&gt;dear reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use both internet = No and Internet=Yes and if No then consider&amp;nbsp;internet_cost=0 and if yes then consider&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; Internet&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Yes'&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; INTERNET_COST &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;InternetDays&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4.95&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;9.95&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but if internet&amp;nbsp;=NO then Internet_cost=0 .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so the code would be below , plz advise , and also how to add $ sign in the column result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;Data&lt;/SPAN&gt; Format2&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
&lt;SPAN class="token keyword"&gt;SET&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;FORMAT&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;BR /&gt;if Internet=No then Internet_Cost = 0
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; Internet&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Yes'&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; INTERNET_COST &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;InternetDays&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4.95&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;9.95&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;* STORE RESULTS IN VARIABLE;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="token comment"&gt;*PRINT RESULTS TO WINDOW FOR DISPLAY;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;print&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;format2&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 08:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303437#M64457</guid>
      <dc:creator>azee007</dc:creator>
      <dc:date>2016-10-09T08:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS IF is No then process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303439#M64458</link>
      <description>&lt;P&gt;Make sure the No is in quotation marks since it's a string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To add $ sign format&amp;nbsp;the variable &amp;nbsp;using dollar12.2&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 08:32:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303439#M64458</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-09T08:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS IF is No then process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303448#M64460</link>
      <description>Dear Reeze,&lt;BR /&gt;&lt;BR /&gt;if Internet= 'Yes' then INTERNET_COST = (InternetDays*4.95)+9.95; THIS IS COMING EMPTY COLUMN. there are days in InternetDays but it is not * with 4.95 and adding to 9.95 .&lt;BR /&gt;&lt;BR /&gt;Secondly where i should use dollar12.2 , like where i am using Internet_cost dollar12.2 in if statement or i have use it separately for SAS to read .&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 09 Oct 2016 08:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303448#M64460</guid>
      <dc:creator>azee007</dc:creator>
      <dc:date>2016-10-09T08:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS IF is No then process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303451#M64462</link>
      <description>&lt;P&gt;Post an example of your first case. Most likely it's not Yes, since it has to be an exact match. yes, YES are not the same, string comparisons are case sensitive. If it's something like this use the UPCASE function to convert everything to all caps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If upcase(internet) = 'YES' ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the dollar sign apply a format, same as you did fo date variables to control the display.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Format internet_cost dollar12.2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;As I mentioned these are base concepts. Please consider taking that course.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2016 10:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303451#M64462</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-09T10:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS IF is No then process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303515#M64493</link>
      <description>&lt;P&gt;Just to add to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;'s excellent advice, whilst learning Base SAS, you can also learn various functions which will improve programming efficiency, one of which is the ifn/ifc function, for example:&lt;/P&gt;
&lt;PRE&gt;data want; 
  set have;
  internet_cost=ifn(upcase(internet)="YES",(internetdays*4.95)+9.95,0);
  format internet_cost dollar12.2;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;Also, some other tips - calling a dataset format is not a good idea unless it is a formats dataset. &amp;nbsp;Not forgetting consistent casing, indentation, finishing code blocks (you didn't use and end for the do in your first example for instance). &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2016 08:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303515#M64493</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-10T08:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS IF is No then process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303616#M64523</link>
      <description>Thankyou very much. Your example really helped my code . Its long code and i was sharing a small part of it , so was not able to get right answers . But your example helped me to get results error free.</description>
      <pubDate>Mon, 10 Oct 2016 17:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-IF-is-No-then-process/m-p/303616#M64523</guid>
      <dc:creator>azee007</dc:creator>
      <dc:date>2016-10-10T17:24:21Z</dc:date>
    </item>
  </channel>
</rss>

