<?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: How to create a table in sas which has cumulative formulas used to derive the observations? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-in-sas-which-has-cumulative-formulas-used/m-p/743513#M232809</link>
    <description>&lt;P&gt;You have much better chances of getting an answer if you supply the input data (and maybe also the output you want) in a datastep, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date date9. amount_at_start Spend savings charge_percentage;
format date date9.;
cards;
17-Apr-21 100.00 10.00 0.00 10.00	
18-Apr-21 . 0.00 0.00 10.00
19-Apr-21 . 0.00 0.00 10.00
20-Apr-21 . 0.00 0.00 10.00
21-Apr-21 . 20.00 40.00 10.00
22-Apr-21 . 0.00 0.00 10.00
23-Apr-21 . 0.00 0.00 10.00
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think you can get the data you want like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  retain amount_at_end 0;
  if missing(amount_at_start) then amount_at_start=amount_at_end;
  amount_at_end=amount_at_start+spend-savings;
  charge_amount= round((charge_percentage/100)*1/365*amount_at_end,0.01);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 May 2021 10:12:24 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2021-05-25T10:12:24Z</dc:date>
    <item>
      <title>How to create a table in sas which has cumulative formulas used to derive the observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-in-sas-which-has-cumulative-formulas-used/m-p/743378#M232730</link>
      <description>&lt;P&gt;I have a table in excel and I need to create a similar table in sas.&lt;/P&gt;
&lt;P&gt;The table is like this:&lt;/P&gt;
&lt;TABLE width="590"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="53px"&gt;DATE&lt;/TD&gt;
&lt;TD width="127px"&gt;amount_at_start&lt;/TD&gt;
&lt;TD width="58px"&gt;Spend&lt;/TD&gt;
&lt;TD width="66px"&gt;savings&lt;/TD&gt;
&lt;TD width="123px"&gt;amount_at_end&lt;/TD&gt;
&lt;TD width="149px"&gt;charge_percentage&lt;/TD&gt;
&lt;TD width="43px"&gt;charge_amount&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53px"&gt;17-Apr-21&lt;/TD&gt;
&lt;TD width="127px"&gt;100.00&lt;/TD&gt;
&lt;TD width="58px"&gt;10.00&lt;/TD&gt;
&lt;TD width="66px"&gt;0.00&lt;/TD&gt;
&lt;TD width="123px"&gt;110.00&lt;/TD&gt;
&lt;TD width="149px"&gt;10.00&lt;/TD&gt;
&lt;TD width="43px"&gt;0.03&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53px"&gt;18-Apr-21&lt;/TD&gt;
&lt;TD width="127px"&gt;110.00&lt;/TD&gt;
&lt;TD width="58px"&gt;0.00&lt;/TD&gt;
&lt;TD width="66px"&gt;0.00&lt;/TD&gt;
&lt;TD width="123px"&gt;110.00&lt;/TD&gt;
&lt;TD width="149px"&gt;10.00&lt;/TD&gt;
&lt;TD width="43px"&gt;0.03&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53px"&gt;19-Apr-21&lt;/TD&gt;
&lt;TD width="127px"&gt;110.00&lt;/TD&gt;
&lt;TD width="58px"&gt;0.00&lt;/TD&gt;
&lt;TD width="66px"&gt;0.00&lt;/TD&gt;
&lt;TD width="123px"&gt;110.00&lt;/TD&gt;
&lt;TD width="149px"&gt;10.00&lt;/TD&gt;
&lt;TD width="43px"&gt;0.03&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53px"&gt;20-Apr-21&lt;/TD&gt;
&lt;TD width="127px"&gt;110.00&lt;/TD&gt;
&lt;TD width="58px"&gt;0.00&lt;/TD&gt;
&lt;TD width="66px"&gt;0.00&lt;/TD&gt;
&lt;TD width="123px"&gt;110.00&lt;/TD&gt;
&lt;TD width="149px"&gt;10.00&lt;/TD&gt;
&lt;TD width="43px"&gt;0.03&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53px"&gt;21-Apr-21&lt;/TD&gt;
&lt;TD width="127px"&gt;110.00&lt;/TD&gt;
&lt;TD width="58px"&gt;20.00&lt;/TD&gt;
&lt;TD width="66px"&gt;40.00&lt;/TD&gt;
&lt;TD width="123px"&gt;90.00&lt;/TD&gt;
&lt;TD width="149px"&gt;10.00&lt;/TD&gt;
&lt;TD width="43px"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53px"&gt;22-Apr-21&lt;/TD&gt;
&lt;TD width="127px"&gt;90.00&lt;/TD&gt;
&lt;TD width="58px"&gt;0.00&lt;/TD&gt;
&lt;TD width="66px"&gt;0.00&lt;/TD&gt;
&lt;TD width="123px"&gt;90.00&lt;/TD&gt;
&lt;TD width="149px"&gt;10.00&lt;/TD&gt;
&lt;TD width="43px"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53px"&gt;23-Apr-21&lt;/TD&gt;
&lt;TD width="127px"&gt;90.00&lt;/TD&gt;
&lt;TD width="58px"&gt;0.00&lt;/TD&gt;
&lt;TD width="66px"&gt;0.00&lt;/TD&gt;
&lt;TD width="123px"&gt;90.00&lt;/TD&gt;
&lt;TD width="149px"&gt;10.00&lt;/TD&gt;
&lt;TD width="43px"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The formulas used in the table are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the first observation for amount_at_start is known to us, but thereafter next row onwards, amount_at_start=amount_at_end from previous row&lt;/LI&gt;
&lt;LI&gt;spend and savings figures for each date is already given to us.&lt;/LI&gt;
&lt;LI&gt;amount_at_end= (amount_at_start +spend _savings)&lt;/LI&gt;
&lt;LI&gt;charge_percentage is known to us&lt;/LI&gt;
&lt;LI&gt;charge_amount= (charge_percentage/100)*1/365*amount_at_end&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;This calculation is happening date wise row by row.&lt;/P&gt;
&lt;P&gt;So if we have the first entry of amount_at_start, all the entries of spends and savings, and the charge_percentage given to us, how do we create a similar table in SAS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help on this would be much appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 14:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-in-sas-which-has-cumulative-formulas-used/m-p/743378#M232730</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-05-24T14:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table in sas which has cumulative formulas used to derive the observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-in-sas-which-has-cumulative-formulas-used/m-p/743513#M232809</link>
      <description>&lt;P&gt;You have much better chances of getting an answer if you supply the input data (and maybe also the output you want) in a datastep, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date date9. amount_at_start Spend savings charge_percentage;
format date date9.;
cards;
17-Apr-21 100.00 10.00 0.00 10.00	
18-Apr-21 . 0.00 0.00 10.00
19-Apr-21 . 0.00 0.00 10.00
20-Apr-21 . 0.00 0.00 10.00
21-Apr-21 . 20.00 40.00 10.00
22-Apr-21 . 0.00 0.00 10.00
23-Apr-21 . 0.00 0.00 10.00
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think you can get the data you want like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  retain amount_at_end 0;
  if missing(amount_at_start) then amount_at_start=amount_at_end;
  amount_at_end=amount_at_start+spend-savings;
  charge_amount= round((charge_percentage/100)*1/365*amount_at_end,0.01);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 May 2021 10:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-in-sas-which-has-cumulative-formulas-used/m-p/743513#M232809</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-05-25T10:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table in sas which has cumulative formulas used to derive the observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-in-sas-which-has-cumulative-formulas-used/m-p/745278#M233584</link>
      <description>&lt;P&gt;The retain statement is useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0t2ac0tfzcgbjn112mu96hkgg9o.htm#p115mm1hsepln9n11cxtkk7wejim" target="_blank"&gt;SAS Help Center: RETAIN Statement&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/casdspgm/p10ux48pz7qknzn1ux1bs48vplnx.htm#n05jzo5a7djwphn1neq15j5m50iw" target="_blank"&gt;SAS Help Center: Manipulate Variables&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 18:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-in-sas-which-has-cumulative-formulas-used/m-p/745278#M233584</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-06-02T18:50:25Z</dc:date>
    </item>
  </channel>
</rss>

