<?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 output a new data set contains sum of certain variables only in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38484#M9875</link>
    <description>hi, thanks for ur reply. the ***stand for the sum of the column based same date same eid, it could  be sum of duration, sum of scale, sum of intake, sum of headdown. date is input as numeric variale.  i used &lt;BR /&gt;
&lt;BR /&gt;
proc print;&lt;BR /&gt;
sum duration headdown intake;&lt;BR /&gt;
by eid date;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
got a output with the grand i want, but with the original data printed out as well. &lt;BR /&gt;
&lt;BR /&gt;
thanks for ur continuous reply.</description>
    <pubDate>Tue, 23 Nov 2010 04:16:03 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-11-23T04:16:03Z</dc:date>
    <item>
      <title>How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38480#M9871</link>
      <description>I got hundreds rows of raw data,&lt;BR /&gt;
used sum function and&lt;BR /&gt;
       by statement  (by two criteria),&lt;BR /&gt;
how could I get a new data set only containing the total of each&lt;BR /&gt;
variables,&lt;BR /&gt;
and get rid of hundreds rows of raw data?&lt;BR /&gt;
&lt;BR /&gt;
thanks a lot</description>
      <pubDate>Mon, 22 Nov 2010 22:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38480#M9871</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-22T22:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38481#M9872</link>
      <description>Hi:&lt;BR /&gt;
  It sort of depends on what you mean by "only containing the total of each variable"?? For example, let's say I have this data:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Name       Sex    Age    Height    Weight&lt;BR /&gt;
&lt;BR /&gt;
Alfred      M      14     69.0      112.5&lt;BR /&gt;
Alice       F      13     56.5       84.0&lt;BR /&gt;
Barbara     F      13     65.3       98.0&lt;BR /&gt;
Carol       F      14     62.8      102.5&lt;BR /&gt;
Henry       M      14     63.5      102.5&lt;BR /&gt;
James       M      12     57.3       83.0&lt;BR /&gt;
Jane        F      12     59.8       84.5&lt;BR /&gt;
Janet       F      15     62.5      112.5&lt;BR /&gt;
Jeffrey     M      13     62.5       84.0&lt;BR /&gt;
John        M      12     59.0       99.5&lt;BR /&gt;
Joyce       F      11     51.3       50.5&lt;BR /&gt;
Judy        F      14     64.3       90.0&lt;BR /&gt;
Louise      F      12     56.3       77.0&lt;BR /&gt;
Mary        F      15     66.5      112.0&lt;BR /&gt;
Philip      M      16     72.0      150.0&lt;BR /&gt;
Robert      M      12     64.8      128.0&lt;BR /&gt;
Ronald      M      15     67.0      133.0&lt;BR /&gt;
Thomas      M      11     57.5       85.0&lt;BR /&gt;
William     M      15     66.5      112.0&lt;BR /&gt;
[/pre]&lt;BR /&gt;
            &lt;BR /&gt;
which actually happens to be the variables and observations in SASHELP.CLASS. How can you describe what you want in terms of these 19 observations??? Would you want to see the total of AGE, HEIGHT and WEIGHT across all observations -- which would be a summary dataset of 1 observation)??? Or, the total of AGE, HEIGHT and WEIGHT for each value of the SEX variable??? (resulting in a summary dataset of 2 observations)??&lt;BR /&gt;
 &lt;BR /&gt;
Different ways to create summary datasets are with PROC MEANS, PROC TABULATE, and PROC REPORT for just a start.&lt;BR /&gt;
                 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 22 Nov 2010 22:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38481#M9872</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-22T22:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38482#M9873</link>
      <description>Thanks Cynthia, &lt;BR /&gt;
&lt;BR /&gt;
Let me use my example to make my question clearly. &lt;BR /&gt;
for example, I have data set like this, &lt;BR /&gt;
I want the report to contain the sum of duration based on each day and each EID like the example listed as following:&lt;BR /&gt;
&lt;BR /&gt;
example of output: &lt;BR /&gt;
EID                          date           sumscale &lt;BR /&gt;
982000099158158	5/12/2008      *****&lt;BR /&gt;
982000099158158	5/13/2008      *****&lt;BR /&gt;
982000099158165	5/27/2008      *****&lt;BR /&gt;
982000099158165	5/28/2008      *****&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data set: &lt;BR /&gt;
EID                           date         scale        duration    headdown   intake&lt;BR /&gt;
982000099158158	5/12/2008	4	8	8	30&lt;BR /&gt;
982000099158158	5/12/2008	3	220	120	60&lt;BR /&gt;
982000099158158	5/12/2008	4	61	28	10&lt;BR /&gt;
982000099158158	5/12/2008	3	43	18	0&lt;BR /&gt;
982000099158158	5/12/2008	3	92	32	10&lt;BR /&gt;
982000099158158	5/12/2008	3	66	22	0&lt;BR /&gt;
982000099158158	5/12/2008	4	140	36	20&lt;BR /&gt;
982000099158158	5/12/2008	4	68	60	10&lt;BR /&gt;
982000099158158	5/13/2008	4	51	22	10&lt;BR /&gt;
982000099158158	5/13/2008	4	16	10	120&lt;BR /&gt;
982000099158158	5/13/2008	3	31	12	170&lt;BR /&gt;
982000099158158	5/13/2008	3	12	10	60&lt;BR /&gt;
982000099158158	5/13/2008	3	11	6	20&lt;BR /&gt;
982000099158165	5/22/2008	27	84	56	0&lt;BR /&gt;
982000099158165	5/23/2008	27	287	104	0&lt;BR /&gt;
982000099158165	5/23/2008	27	93	52	0&lt;BR /&gt;
982000099158165	5/23/2008	27	29	12	100&lt;BR /&gt;
982000099158165	5/23/2008	27	92	74	310&lt;BR /&gt;
982000099158165	5/23/2008	27	259	142	490&lt;BR /&gt;
982000099158165	5/23/2008	27	242	138	630&lt;BR /&gt;
982000099158165	5/23/2008	27	154	104	210&lt;BR /&gt;
982000099158165	5/23/2008	27	129	74	450&lt;BR /&gt;
982000099158165	5/23/2008	27	318	198	890&lt;BR /&gt;
982000099158165	5/23/2008	27	546	350	1310&lt;BR /&gt;
982000099158165	5/23/2008	27	53	38	240&lt;BR /&gt;
982000099158165	5/23/2008	27	54	34	290&lt;BR /&gt;
982000099158165	5/23/2008	27	402	260	1000&lt;BR /&gt;
982000099158165	5/23/2008	27	492	282	800&lt;BR /&gt;
982000099158165	5/24/2008	27	308	140	390&lt;BR /&gt;
982000099158165	5/24/2008	27	1092	344	0&lt;BR /&gt;
982000099158165	5/24/2008	27	199	94	3320&lt;BR /&gt;
982000099158165	5/24/2008	27	525	150	530</description>
      <pubDate>Mon, 22 Nov 2010 23:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38482#M9873</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-22T23:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38483#M9874</link>
      <description>Hi,&lt;BR /&gt;
  Just curious -- what does the ***** for SUMSCALE represent in your post??? Only the sum of DURATION??? Or, could that be the sum of the SCALE variable? You say you want the sum of DURATION, but what about the SCALE, HEADDOWN and INTAKE variables? So you want to see their sums as well???&lt;BR /&gt;
&lt;BR /&gt;
  Have you tried any SAS procedures already?? Do you already have a SAS dataset??? Is the date value a character variable or a numeric variable?? &lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 23 Nov 2010 03:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38483#M9874</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-23T03:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38484#M9875</link>
      <description>hi, thanks for ur reply. the ***stand for the sum of the column based same date same eid, it could  be sum of duration, sum of scale, sum of intake, sum of headdown. date is input as numeric variale.  i used &lt;BR /&gt;
&lt;BR /&gt;
proc print;&lt;BR /&gt;
sum duration headdown intake;&lt;BR /&gt;
by eid date;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
got a output with the grand i want, but with the original data printed out as well. &lt;BR /&gt;
&lt;BR /&gt;
thanks for ur continuous reply.</description>
      <pubDate>Tue, 23 Nov 2010 04:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38484#M9875</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-23T04:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38485#M9876</link>
      <description>Hi:&lt;BR /&gt;
  Have you looked at any of the following procedures: PROC MEANS, PROC TABULATE, PROC REPORT???&lt;BR /&gt;
 &lt;BR /&gt;
  They will all create output datasets, summarized, as you desire. The syntax of each procedure is slightly different, but there are many examples in the documentation and in previous forum postings, such as this one, which showed how to get the SUM and the MEDIAN statistic:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=41940ꏔ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=41940ꏔ&lt;/A&gt;&lt;BR /&gt;
or these:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=45689뉹" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=45689뉹&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=11068⬼" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=11068⬼&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 23 Nov 2010 05:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38485#M9876</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-23T05:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38486#M9877</link>
      <description>Hello Sasha,&lt;BR /&gt;
&lt;BR /&gt;
Assume that a name for your input dataset is A then possible solution for sum of Scale grouped by EID and Date could be like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc means data=a nway noprint;&lt;BR /&gt;
  output out=sumscale SUM=sumscale;&lt;BR /&gt;
  var scale;&lt;BR /&gt;
  class EID date;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Output data set is SUMSCALE.&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 23 Nov 2010 14:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38486#M9877</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-23T14:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38487#M9878</link>
      <description>Hi SPR, &lt;BR /&gt;
&lt;BR /&gt;
thanks a lot!. That works, but I guess if I want to sumof scale, sum of intake, sum of duration showing up at same time, I need do three proc means, and get three output data set, correct?</description>
      <pubDate>Tue, 23 Nov 2010 15:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38487#M9878</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-23T15:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38488#M9879</link>
      <description>Hey, Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
I followed the example you gave me in the first link;&lt;BR /&gt;
I used the proc report as following:&lt;BR /&gt;
&lt;BR /&gt;
  proc report data=amanagsdata nowd split='/'&lt;BR /&gt;
  out=work.report;&lt;BR /&gt;
  column EID date duration headdown consumed;&lt;BR /&gt;
  define EID /group;&lt;BR /&gt;
  define date /group;&lt;BR /&gt;
  define duration/sum  'sum/duration';&lt;BR /&gt;
  define headdown/sum 'sum/headdown';&lt;BR /&gt;
  define consumed/sum 'sum/consumed';&lt;BR /&gt;
  run; &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
it works for me.&lt;BR /&gt;
Thanks very much!!!!!&lt;BR /&gt;
Have a good day and thanksgiving

Message was edited by: Sasha</description>
      <pubDate>Tue, 23 Nov 2010 15:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38488#M9879</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-11-23T15:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38489#M9880</link>
      <description>Hi:&lt;BR /&gt;
  I'm glad you got PROC REPORT working. PROC MEANS could also give you multiple summed variables, as shown in the code below (along with a TABULATE for comparison of what the different syntax and output datasets look like).&lt;BR /&gt;
 &lt;BR /&gt;
  Just an FYI -- the label that you specify for the PROC REPORT step does NOT get used in WORK.REPORT when it gets created.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc means data=amanagsdata  nway sum;&lt;BR /&gt;
  title 'PROC MEANS';&lt;BR /&gt;
  class EID date;&lt;BR /&gt;
  var scale duration headdown consumed;&lt;BR /&gt;
  output out=work.mnout sum=sumscale sumdur sumhdwn sumcons;&lt;BR /&gt;
  format date mmddyy10.;&lt;BR /&gt;
run;&lt;BR /&gt;
               &lt;BR /&gt;
proc tabulate data=amanagsdata  f=comma9.&lt;BR /&gt;
     out=work.tabout;&lt;BR /&gt;
  title 'PROC TABULATE';&lt;BR /&gt;
  class EID date;&lt;BR /&gt;
  var scale duration headdown consumed;&lt;BR /&gt;
  table EID*date,&lt;BR /&gt;
        sum*(scale duration headdown consumed) / rts=50;&lt;BR /&gt;
  format date mmddyy10.;&lt;BR /&gt;
run;&lt;BR /&gt;
              &lt;BR /&gt;
proc report data=amanagsdata  nowd&lt;BR /&gt;
     out=work.repout;&lt;BR /&gt;
  title 'PROC REPORT';&lt;BR /&gt;
  column EID date scale duration headdown consumed;&lt;BR /&gt;
  define EID / group;&lt;BR /&gt;
  define date / group order=internal f=mmddyy10.;&lt;BR /&gt;
  define scale / sum;&lt;BR /&gt;
  define duration / sum;&lt;BR /&gt;
  define headdown / sum;&lt;BR /&gt;
  define consumed / sum;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 23 Nov 2010 15:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38489#M9880</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-23T15:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38490#M9881</link>
      <description>It depends... You can have a single proc MEANS with &lt;BR /&gt;
&lt;BR /&gt;
var SCALE  INTAKE DURATION;&lt;BR /&gt;
&lt;BR /&gt;
Then you will get all three sums in one datasset.&lt;BR /&gt;
&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 23 Nov 2010 16:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38490#M9881</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-23T16:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a new data set contains sum of certain variables only</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38491#M9882</link>
      <description>Sasha &lt;BR /&gt;
as SPR says yu can get all your totals in one pass of proc means.&lt;BR /&gt;
&lt;BR /&gt;
 If  your request to reduce the data to totals and "by variables" then try:&lt;BR /&gt;
proc means data= your.data missing nway ;&lt;BR /&gt;
   class by_var1 by_var2 ;&lt;BR /&gt;
   var  _numeric_ ;&lt;BR /&gt;
   output out= totals_dataset sum= ;&lt;BR /&gt;
run ;&lt;BR /&gt;
You have to replace your.data and by_var1 by_var2 with your context.&lt;BR /&gt;
You do not need to name each numeric variable if all are required to be totalled, but replace _numeric_ with a reduced list  if you want only a few of the numerics totalled. (class vars won't be totalled anyway) &lt;BR /&gt;
That provides an output data set the example names totals_dataset, but change that to whatever you prefer.&lt;BR /&gt;
Fundamentally simple for simple requests. - that's SAS&lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Tue, 23 Nov 2010 17:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-output-a-new-data-set-contains-sum-of-certain-variables/m-p/38491#M9882</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-23T17:02:04Z</dc:date>
    </item>
  </channel>
</rss>

