<?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 YTD  calculation on the fly or with a table creation - stored process or EG in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/YTD-calculation-on-the-fly-or-with-a-table-creation-stored/m-p/26864#M6177</link>
    <description>YTD calculation should be based on the selected value in the time filter. As an example, if we put 'Feb-2010', then &lt;BR /&gt;
YTD unit_cost for each specific 'scenario-period-sku-resource combination' calculated as total cost (4+7)/total output(10+13)., based on below data. Likewise for other categories and the YTD section looks like the output below with the given dataset = test.&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input scenario $ period $ sku $ resource $ cost output;&lt;BR /&gt;
cards;&lt;BR /&gt;
Actual Jan-10 sku1 Material 4 10&lt;BR /&gt;
Actual Jan-10 sku1 labor 5 11&lt;BR /&gt;
Actual Jan-10 sku1 overhead 6 12&lt;BR /&gt;
Actual Feb-10 sku1 Material 7 13&lt;BR /&gt;
Actual Feb-10 sku1 Labor 8 14&lt;BR /&gt;
Actual Feb-10 sku1 overhead 9 15&lt;BR /&gt;
Actual Mar-10 sku1 Material 1 5&lt;BR /&gt;
Actual Mar-10 sku1 labor 2 6&lt;BR /&gt;
Actual Mar-10 sku1 overhead 3 7&lt;BR /&gt;
Actual Jan-10 sku2 Material 5 5&lt;BR /&gt;
Actual Jan-10 sku2 labor 6 6&lt;BR /&gt;
Actual Jan-10 sku2 overhead 7 7&lt;BR /&gt;
Budget 2010 sku1 Material 4 10&lt;BR /&gt;
Budget 2010 sku1 labor 5 10&lt;BR /&gt;
Budget 2010 sku1 overhead 6 12&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;Required Final output:&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Mar-10	Actual				Budget				 YTD Actual				YTD Budget			&lt;BR /&gt;
	Material---Labor---Overhead---Total---Material---Labor---Overhead---Total---Material---Labor---Overhead---Total---Material---Labor---Overhead---Total&lt;BR /&gt;
sku1---	0.4---	0.5---	0.6---	1.5---	0.4---	0.5---	0.6---	1.5---	0.48---	0.52---	0.56---	1.55---	0.4---	0.5---	0.6---1.5---&lt;BR /&gt;
&lt;BR /&gt;
I would prefer time filter as a macro variable and YTD calculation happens after selecting the time period but temporary table creation with YTD field on it, will also work. From the created table, I can pull the records based on the 'time filter'. &lt;BR /&gt;
&lt;BR /&gt;
The developed code so far looks like without YTD calculation.&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
set test;&lt;BR /&gt;
unit_cost=cost/output;&lt;BR /&gt;
format unit_cost 8.1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=test nowd headline headskip;&lt;BR /&gt;
where period in ('Jan-10','2010'); /*Date filter*/&lt;BR /&gt;
column sku scenario,(resource, cost1 total);&lt;BR /&gt;
define sku / group;&lt;BR /&gt;
define scenario / across;&lt;BR /&gt;
define resource / across order=data;&lt;BR /&gt;
define unit_cost / sum;&lt;BR /&gt;
define total / computed;&lt;BR /&gt;
&lt;BR /&gt;
compute total;&lt;BR /&gt;
_c5_=sum(_c2_,_c3_,_c4_);&lt;BR /&gt;
_c9_=sum(_c6_,_c7_,_c8_);&lt;BR /&gt;
endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your help</description>
    <pubDate>Mon, 24 May 2010 23:54:19 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-05-24T23:54:19Z</dc:date>
    <item>
      <title>YTD  calculation on the fly or with a table creation - stored process or EG</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/YTD-calculation-on-the-fly-or-with-a-table-creation-stored/m-p/26864#M6177</link>
      <description>YTD calculation should be based on the selected value in the time filter. As an example, if we put 'Feb-2010', then &lt;BR /&gt;
YTD unit_cost for each specific 'scenario-period-sku-resource combination' calculated as total cost (4+7)/total output(10+13)., based on below data. Likewise for other categories and the YTD section looks like the output below with the given dataset = test.&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input scenario $ period $ sku $ resource $ cost output;&lt;BR /&gt;
cards;&lt;BR /&gt;
Actual Jan-10 sku1 Material 4 10&lt;BR /&gt;
Actual Jan-10 sku1 labor 5 11&lt;BR /&gt;
Actual Jan-10 sku1 overhead 6 12&lt;BR /&gt;
Actual Feb-10 sku1 Material 7 13&lt;BR /&gt;
Actual Feb-10 sku1 Labor 8 14&lt;BR /&gt;
Actual Feb-10 sku1 overhead 9 15&lt;BR /&gt;
Actual Mar-10 sku1 Material 1 5&lt;BR /&gt;
Actual Mar-10 sku1 labor 2 6&lt;BR /&gt;
Actual Mar-10 sku1 overhead 3 7&lt;BR /&gt;
Actual Jan-10 sku2 Material 5 5&lt;BR /&gt;
Actual Jan-10 sku2 labor 6 6&lt;BR /&gt;
Actual Jan-10 sku2 overhead 7 7&lt;BR /&gt;
Budget 2010 sku1 Material 4 10&lt;BR /&gt;
Budget 2010 sku1 labor 5 10&lt;BR /&gt;
Budget 2010 sku1 overhead 6 12&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;Required Final output:&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Mar-10	Actual				Budget				 YTD Actual				YTD Budget			&lt;BR /&gt;
	Material---Labor---Overhead---Total---Material---Labor---Overhead---Total---Material---Labor---Overhead---Total---Material---Labor---Overhead---Total&lt;BR /&gt;
sku1---	0.4---	0.5---	0.6---	1.5---	0.4---	0.5---	0.6---	1.5---	0.48---	0.52---	0.56---	1.55---	0.4---	0.5---	0.6---1.5---&lt;BR /&gt;
&lt;BR /&gt;
I would prefer time filter as a macro variable and YTD calculation happens after selecting the time period but temporary table creation with YTD field on it, will also work. From the created table, I can pull the records based on the 'time filter'. &lt;BR /&gt;
&lt;BR /&gt;
The developed code so far looks like without YTD calculation.&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
set test;&lt;BR /&gt;
unit_cost=cost/output;&lt;BR /&gt;
format unit_cost 8.1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=test nowd headline headskip;&lt;BR /&gt;
where period in ('Jan-10','2010'); /*Date filter*/&lt;BR /&gt;
column sku scenario,(resource, cost1 total);&lt;BR /&gt;
define sku / group;&lt;BR /&gt;
define scenario / across;&lt;BR /&gt;
define resource / across order=data;&lt;BR /&gt;
define unit_cost / sum;&lt;BR /&gt;
define total / computed;&lt;BR /&gt;
&lt;BR /&gt;
compute total;&lt;BR /&gt;
_c5_=sum(_c2_,_c3_,_c4_);&lt;BR /&gt;
_c9_=sum(_c6_,_c7_,_c8_);&lt;BR /&gt;
endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your help</description>
      <pubDate>Mon, 24 May 2010 23:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/YTD-calculation-on-the-fly-or-with-a-table-creation-stored/m-p/26864#M6177</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-05-24T23:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: YTD  calculation on the fly or with a table creation - stored process or EG</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/YTD-calculation-on-the-fly-or-with-a-table-creation-stored/m-p/26865#M6178</link>
      <description>I guess in my previous question, I combined multiple tasks at one time and complicated the issue. I need to do YTD calculation for cost by group variables.&lt;BR /&gt;
&lt;BR /&gt;
In this case, I would like to have accumulating cost by  scenario $ resource $ sku $ for each month. Thanks</description>
      <pubDate>Tue, 25 May 2010 14:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/YTD-calculation-on-the-fly-or-with-a-table-creation-stored/m-p/26865#M6178</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-05-25T14:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: YTD  calculation on the fly or with a table creation - stored process or EG</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/YTD-calculation-on-the-fly-or-with-a-table-creation-stored/m-p/26866#M6179</link>
      <description>you can use proc tabulate&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data test2;&lt;BR /&gt;
set test;&lt;BR /&gt;
if index(period,'10') then ytd = 10;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data = test2;&lt;BR /&gt;
     var cost;&lt;BR /&gt;
     class ytd scenario sku resource;&lt;BR /&gt;
     table sku * resource * scenario  , ytd * cost ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
GL.</description>
      <pubDate>Tue, 25 May 2010 16:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/YTD-calculation-on-the-fly-or-with-a-table-creation-stored/m-p/26866#M6179</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-05-25T16:14:55Z</dc:date>
    </item>
  </channel>
</rss>

