<?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: Subtraction function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80906#M17426</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul, Depends upon what you need.&amp;nbsp; I didn't even see the part of your post concerning previous record.&amp;nbsp; Since the sum function retains a value across records, it could be used to start with a value and then subtract a current record's value from it.&amp;nbsp; The dif function would just get the difference between the current and previous record.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Nov 2012 22:09:16 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-11-26T22:09:16Z</dc:date>
    <item>
      <title>Subtraction function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80902#M17422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have used the sum function in a data step to add the value of a previous row to a current one. I was wondering if there is something similar for subtracting a value in a previous row from a value in the current data set? I did not see anything for 'subtract' and tried adding a negative value using the sum function but that did not work either:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data s1AgeCleanCare1;&lt;/P&gt;&lt;P&gt;set s1AgeCleanSort1;&lt;/P&gt;&lt;P&gt;by cnty_name startyear agecat4 exitMonthCategory;&lt;/P&gt;&lt;P&gt;if first.agecat4 then CumulativeNumber=OutOfHomeCare;&lt;/P&gt;&lt;P&gt;OutOfHomeCare + (-CumulativeNumber);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2012 20:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80902#M17422</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2012-11-26T20:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Subtraction function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80903#M17423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DIF (var) function, similar to LAG in concept, will give the difference from the previous record and the current or up to 99 records for a variable depending on DIF, DIF2, ..., DIF99. However you don't want to use it after IF statements as you will likely get unexpected results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2012 20:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80903#M17423</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-11-26T20:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Subtraction function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80904#M17424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Couldn't you just use sum(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;OutOfHomeCare-CumulativeNumber);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is documented at: &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245953.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245953.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245953.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2012 20:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80904#M17424</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-26T20:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Subtraction function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80905#M17425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I did the sum() above and that worked for me, but I think the DIF would work as well. Thank you both.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2012 22:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80905#M17425</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2012-11-26T22:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Subtraction function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80906#M17426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul, Depends upon what you need.&amp;nbsp; I didn't even see the part of your post concerning previous record.&amp;nbsp; Since the sum function retains a value across records, it could be used to start with a value and then subtract a current record's value from it.&amp;nbsp; The dif function would just get the difference between the current and previous record.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2012 22:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80906#M17426</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-26T22:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Subtraction function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80907#M17427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thats all I need in this particular situation actually: current - previous.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2012 22:27:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80907#M17427</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2012-11-26T22:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Subtraction function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80908#M17428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and take a look at function range();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data _null_;
a=4; b=1;
x=range(a,b);
put x=;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Nov 2012 04:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtraction-function/m-p/80908#M17428</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-11-28T04:07:52Z</dc:date>
    </item>
  </channel>
</rss>

