<?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 Summing Based on condition for Year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10254#M715</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys, I have following dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt;input year 4. price1 price2 Price3&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;2002 100 200 500&lt;/P&gt;&lt;P&gt;2006 600 . 700&lt;/P&gt;&lt;P&gt;2001 500 400 .&lt;/P&gt;&lt;P&gt;2008 1200 1000 2000&lt;/P&gt;&lt;P&gt;2009 1300 1700 8000&lt;/P&gt;&lt;P&gt;2003 . 500 300&lt;/P&gt;&lt;P&gt;2011 1200 1000 1000&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to have the sum of price1 price2 and price3 in two parts i.e. for current year in one part and for remaining years clubed out together put together in another part. So my output should be like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Year Price1 Price2 Price3&lt;/P&gt;&lt;P&gt;2002 100 200 500&lt;/P&gt;&lt;P&gt;2006 600 . 700&lt;/P&gt;&lt;P&gt;2001 500 400 .&lt;/P&gt;&lt;P&gt;2008 1200 1000 2000&lt;/P&gt;&lt;P&gt;2009 1300 1700 8000&lt;/P&gt;&lt;P&gt;2003 . 500 300&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Total 3700 3800 10200&lt;/P&gt;&lt;P&gt;2011 1200 1000 1000&lt;/P&gt;&lt;P&gt;Total 4900 4800 11200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using data _null_ for preparing the report so I can just use put @ to print out the values what I am concerned about is my if statements.... can somebody help me out with that... Thanks in advance &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Dec 2011 11:40:58 GMT</pubDate>
    <dc:creator>yash82</dc:creator>
    <dc:date>2011-12-07T11:40:58Z</dc:date>
    <item>
      <title>Summing Based on condition for Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10254#M715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys, I have following dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt;input year 4. price1 price2 Price3&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;2002 100 200 500&lt;/P&gt;&lt;P&gt;2006 600 . 700&lt;/P&gt;&lt;P&gt;2001 500 400 .&lt;/P&gt;&lt;P&gt;2008 1200 1000 2000&lt;/P&gt;&lt;P&gt;2009 1300 1700 8000&lt;/P&gt;&lt;P&gt;2003 . 500 300&lt;/P&gt;&lt;P&gt;2011 1200 1000 1000&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to have the sum of price1 price2 and price3 in two parts i.e. for current year in one part and for remaining years clubed out together put together in another part. So my output should be like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Year Price1 Price2 Price3&lt;/P&gt;&lt;P&gt;2002 100 200 500&lt;/P&gt;&lt;P&gt;2006 600 . 700&lt;/P&gt;&lt;P&gt;2001 500 400 .&lt;/P&gt;&lt;P&gt;2008 1200 1000 2000&lt;/P&gt;&lt;P&gt;2009 1300 1700 8000&lt;/P&gt;&lt;P&gt;2003 . 500 300&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Total 3700 3800 10200&lt;/P&gt;&lt;P&gt;2011 1200 1000 1000&lt;/P&gt;&lt;P&gt;Total 4900 4800 11200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using data _null_ for preparing the report so I can just use put @ to print out the values what I am concerned about is my if statements.... can somebody help me out with that... Thanks in advance &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 11:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10254#M715</guid>
      <dc:creator>yash82</dc:creator>
      <dc:date>2011-12-07T11:40:58Z</dc:date>
    </item>
    <item>
      <title>Summing Based on condition for Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10255#M716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi,&lt;/P&gt;&lt;P&gt;Can i suggest trying a normal proc report ... Will it help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if year = 2011 then a=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else a=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; proc report data=x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; column a year price1 price2 price3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; define a / group noprint ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; define year / group;&lt;/P&gt;&lt;P&gt;&amp;nbsp; break after a / summarize;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rbreak after / summarize;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 15:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10255#M716</guid>
      <dc:creator>NN</dc:creator>
      <dc:date>2011-12-07T15:16:00Z</dc:date>
    </item>
    <item>
      <title>Summing Based on condition for Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10256#M717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's a little more complicated doing it in a datastep, rather than using proc report, but you asked:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x (keep=year price:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; input year $ price1-Price3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array iprice(*) price:;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array hprice(3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array tprice(3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain tprice:;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hprice(i)=iprice(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if year eq 2011 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; year="Total";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iprice(i)=tprice(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; year="2011";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iprice(i)=hprice(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tprice(i)=sum(tprice(i),iprice(i));&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if year eq 2011 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; year="Total";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iprice(i)=tprice(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;2002 100 200 500&lt;/P&gt;&lt;P&gt;2006 600 . 700&lt;/P&gt;&lt;P&gt;2001 500 400 .&lt;/P&gt;&lt;P&gt;2008 1200 1000 2000&lt;/P&gt;&lt;P&gt;2009 1300 1700 8000&lt;/P&gt;&lt;P&gt;2003 . 500 300&lt;/P&gt;&lt;P&gt;2011 1200 1000 1000&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 17:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10256#M717</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-12-07T17:41:57Z</dc:date>
    </item>
    <item>
      <title>Summing Based on condition for Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10257#M718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consider using a multilabel format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 20:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10257#M718</guid>
      <dc:creator>Howles</dc:creator>
      <dc:date>2011-12-07T20:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Summing Based on condition for Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10258#M719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... if the data set is in the order you show and that output is all you want using data _null_&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;file print;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;if _n_ eq 1 then put ' YEAR&amp;nbsp; PRICE1&amp;nbsp; PRICE2&amp;nbsp; PRICE3';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;set x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;if year ne 2011 then do;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; put (year price1-price3) (5. 3*8.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; t1+price1; t2+price2; t3+price3;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;else do;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; put / 'TOTAL' (t1-t3) (8.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; put (year price1-price3) (5. 3*8.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; t1+price1; t2+price2; t3+price3;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; put 'TOTAL' (t1-t3) (8.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 23:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10258#M719</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2011-12-07T23:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Summing Based on condition for Year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10259#M720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys... it solved the purpose...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Dec 2011 09:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-Based-on-condition-for-Year/m-p/10259#M720</guid>
      <dc:creator>yash82</dc:creator>
      <dc:date>2011-12-10T09:01:58Z</dc:date>
    </item>
  </channel>
</rss>

