<?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: CONDITIONAL Sum in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64828#M18445</link>
    <description>Hi:&lt;BR /&gt;
  Proc TABULATE would not call that a CONDITIONAL SUM. What you want is a subtotal or total for ALL the values of a CLASS variable. If you look at my previous examples, here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?threadID=8892&amp;amp;tstart=0" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?threadID=8892&amp;amp;tstart=0&lt;/A&gt;&lt;BR /&gt;
you will see that I used the universal class variable ALL in my other posting. If you look up ALL in the TABULATE documentation, you will see why I used it to get a GRAND TOTAL at the bottom of the table:&lt;BR /&gt;
In particular, Example 6 at this site:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473755.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473755.htm&lt;/A&gt;&lt;BR /&gt;
entitled "Summarizing Information with the Universal Class Variable ALL" should be very helpful.&lt;BR /&gt;
&lt;BR /&gt;
And in the paper links I posted, &lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/243-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/243-30.pdf&lt;/A&gt; (page 4, step 4 talks about using ALL)&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/258-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/258-30.pdf&lt;/A&gt; (page 4 also talks about ALL and ALL with generating percents)&lt;BR /&gt;
 &lt;BR /&gt;
This information is still available to you in the documentation and in the program code and the paper links previously posted.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
PS...an additional followup comment. If you want the SUM of total units sold, then you need to use the SUM statistic in your TABULATE code not the MEAN statistic.</description>
    <pubDate>Thu, 04 Mar 2010 19:31:52 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-03-04T19:31:52Z</dc:date>
    <item>
      <title>CONDITIONAL Sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64827#M18444</link>
      <description>Hello All ,&lt;BR /&gt;
&lt;BR /&gt;
I wnat to find the sum of all cells in the column ' Units Sold ' for which I have 'Week 1',..........,'Week 4' in the column  " Week ".This is since I wnat to find a breakdown of the number of Units sold over 4 week time period.&lt;BR /&gt;
&lt;BR /&gt;
I used code -&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=WEEK f=dollar8.;&lt;BR /&gt;
   class week Laptopmodel;&lt;BR /&gt;
   var  UnitsSold;&lt;BR /&gt;
   table week*Laptopmodel,&lt;BR /&gt;
         Unitssold*Mean=" ";&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
It gave me the breakdown by weeks , but didnt give total of the units sold over each period. I need to find the sum of units sold over the 4 week period. I'm not sure if Conditional Sum is possible in SAS . Can I find the sum of the no. of units sold over the 4 week period individually.&lt;BR /&gt;
&lt;BR /&gt;
A sample data is -&lt;BR /&gt;
&lt;BR /&gt;
                Transaction                      Timeof         Laptop    Units&lt;BR /&gt;
         Obs        ID          DateofSale      Sale         Model      Sold    Warranty    Week&lt;BR /&gt;
&lt;BR /&gt;
           1     RX000152      03/11/2009    11:27:53    AP3965      5          1       Week1&lt;BR /&gt;
           2     RX000170      04/11/2009    05:55:50    AT3600      5          1       Week1&lt;BR /&gt;
           3     RX000189      06/11/2009    09:07:45    AT3600      5          1       Week1&lt;BR /&gt;
           4     RX000179      05/11/2009    12:32:28    AP3965      5          0       Week1&lt;BR /&gt;
           5     RX000141      01/11/2009    08:49:26    AT3600      2          1       Week1&lt;BR /&gt;
           6     RX000149      02/11/2009    11:54:23    AP3965      2          1       Week1&lt;BR /&gt;
           7     RX000215      08/11/2009    14:09:49    AP3965      2          1       Week2&lt;BR /&gt;
           8     RX000230      09/11/2009    19:28:32    AP3965      2          1       Week2&lt;BR /&gt;
           9     RX000247      10/11/2009    14:14:41    AP3965      2          1       Week2&lt;BR /&gt;
          10     RX000295      14/11/2009    11:12:00    AP3965      2          1       Week2&lt;BR /&gt;
          11     RX000135      01/11/2009    09:50:39    AP3965      2          0       Week1&lt;BR /&gt;
          12     RX000143      02/11/2009    10:27:08    AP3965      2          0       Week1</description>
      <pubDate>Thu, 04 Mar 2010 17:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64827#M18444</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-03-04T17:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: CONDITIONAL Sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64828#M18445</link>
      <description>Hi:&lt;BR /&gt;
  Proc TABULATE would not call that a CONDITIONAL SUM. What you want is a subtotal or total for ALL the values of a CLASS variable. If you look at my previous examples, here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?threadID=8892&amp;amp;tstart=0" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?threadID=8892&amp;amp;tstart=0&lt;/A&gt;&lt;BR /&gt;
you will see that I used the universal class variable ALL in my other posting. If you look up ALL in the TABULATE documentation, you will see why I used it to get a GRAND TOTAL at the bottom of the table:&lt;BR /&gt;
In particular, Example 6 at this site:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473755.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473755.htm&lt;/A&gt;&lt;BR /&gt;
entitled "Summarizing Information with the Universal Class Variable ALL" should be very helpful.&lt;BR /&gt;
&lt;BR /&gt;
And in the paper links I posted, &lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/243-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/243-30.pdf&lt;/A&gt; (page 4, step 4 talks about using ALL)&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/258-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/258-30.pdf&lt;/A&gt; (page 4 also talks about ALL and ALL with generating percents)&lt;BR /&gt;
 &lt;BR /&gt;
This information is still available to you in the documentation and in the program code and the paper links previously posted.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
PS...an additional followup comment. If you want the SUM of total units sold, then you need to use the SUM statistic in your TABULATE code not the MEAN statistic.</description>
      <pubDate>Thu, 04 Mar 2010 19:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64828#M18445</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-03-04T19:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: CONDITIONAL Sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64829#M18446</link>
      <description>Hello Cynthia ,&lt;BR /&gt;
&lt;BR /&gt;
could you please suggest a change in the code below as i get one log error that The type of name (type) is unknown.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I used the code -&lt;BR /&gt;
&lt;BR /&gt;
/*Format period*/&lt;BR /&gt;
PROC FORMAT;&lt;BR /&gt;
    VALUE perfmt      1='period1'&lt;BR /&gt;
                      2='period2'; &lt;BR /&gt;
    VALUE LapModfmt   1='AP3965'&lt;BR /&gt;
                      2='AT3600';&lt;BR /&gt;
    value usetype     1='AP3965'&lt;BR /&gt;
                         2='AT3600';&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/*Revenue breakdown for the two periods*/&lt;BR /&gt;
proc tabulate data=period format=comma12.;&lt;BR /&gt;
    class period Week ;&lt;BR /&gt;
    var   revenue ;&lt;BR /&gt;
table period*(Week all='Subtotal')&lt;BR /&gt;
         all='Total for All Laptop Models'*f=dollar12.,&lt;BR /&gt;
         type='Laptop Models'*revenue=' '*sum=' '&lt;BR /&gt;
         all='Revenues from both Laptop Models'*revenue=' '*sum=' '&lt;BR /&gt;
        / rts=25;&lt;BR /&gt;
title 'revenues Each Laptop';&lt;BR /&gt;
title2 '(Revenues in Dollars)';&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
The log error -&lt;BR /&gt;
&lt;BR /&gt;
2121  title2 '(Revenues in Dollars)';&lt;BR /&gt;
2122  RUN;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: The type of name (type) is unknown.&lt;BR /&gt;
&lt;BR /&gt;
Could you please suggest a change in the code.&lt;BR /&gt;
&lt;BR /&gt;
Kind  Regards ,&lt;BR /&gt;
mark.</description>
      <pubDate>Tue, 09 Mar 2010 17:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64829#M18446</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-03-09T17:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: CONDITIONAL Sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64830#M18447</link>
      <description>Check this code piece from your PROC TABULATE:&lt;BR /&gt;
&lt;BR /&gt;
revenue=' '*sum=' '&lt;BR /&gt;
&lt;BR /&gt;
Some self-diagnosis by commenting out portions of the code to get back to a working program could help, also,&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 09 Mar 2010 18:16:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64830#M18447</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-09T18:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: CONDITIONAL Sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64831#M18448</link>
      <description>hello ,&lt;BR /&gt;
in the code below :-&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
   value prdfmt   1='Period1'&lt;BR /&gt;
                       2='Period2';&lt;BR /&gt;
   value wkfmt    1='Week1'&lt;BR /&gt;
                        2='Week2'&lt;BR /&gt;
                        3='Week3'&lt;BR /&gt;
                        4='Week4';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
DATA revenue_breakdown;&lt;BR /&gt;
	set period;&lt;BR /&gt;
	FORMAT Period $prdfmt. Week $wkfmt.;&lt;BR /&gt;
	Title ' THe Data Set for revenue_breakdown ';&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
LOG - &lt;BR /&gt;
&lt;BR /&gt;
388      FORMAT Period $prdfmt. Week $wkfmt.;&lt;BR /&gt;
                        --------&lt;BR /&gt;
                        48&lt;BR /&gt;
ERROR 48-59: The format $PRDFMT was not found or could not be&lt;BR /&gt;
             loaded.&lt;BR /&gt;
&lt;BR /&gt;
2388!     FORMAT Period $prdfmt. Week $wkfmt.;&lt;BR /&gt;
                                      -------&lt;BR /&gt;
                                      48&lt;BR /&gt;
ERROR 48-59: The format $WKFMT was not found or could not be&lt;BR /&gt;
             loaded.&lt;BR /&gt;
&lt;BR /&gt;
Kindly guide , where I'm making the mistake.&lt;BR /&gt;
&lt;BR /&gt;
regards,&lt;BR /&gt;
markc</description>
      <pubDate>Tue, 09 Mar 2010 19:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64831#M18448</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-03-09T19:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: CONDITIONAL Sum</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64832#M18449</link>
      <description>Putting "$" before a format name means the &lt;U&gt;variable&lt;/U&gt; that you are associating that format with is character.</description>
      <pubDate>Tue, 09 Mar 2010 19:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/CONDITIONAL-Sum/m-p/64832#M18449</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-03-09T19:55:59Z</dc:date>
    </item>
  </channel>
</rss>

