<?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: Sum up values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712108#M219463</link>
    <description>&lt;P&gt;&lt;SPAN&gt;For total number of observations in one dataset, you can have that value in a macro variable and use that in proc report.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2021 13:14:54 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2021-01-18T13:14:54Z</dc:date>
    <item>
      <title>Sum up values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/711884#M219379</link>
      <description>&lt;P&gt;Hi if I have a date set like:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;ID&lt;/TD&gt;
&lt;TD width="50%"&gt;COUNT&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;TD width="50%"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2&lt;/TD&gt;
&lt;TD width="50%"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;3&lt;/TD&gt;
&lt;TD width="50%"&gt;25&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish to add new columns to the data set, so the output will be this in a proc print:&lt;/P&gt;
&lt;P&gt;A total sum up for the values and then divides with the total with 7.&lt;/P&gt;
&lt;P&gt;It should be a code that can be used for new numbers every week - so I cant enter the numbers manually&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;ID&lt;/TD&gt;
&lt;TD width="50%"&gt;COUNT&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;TD width="50%"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2&lt;/TD&gt;
&lt;TD width="50%"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;3&lt;/TD&gt;
&lt;TD width="50%"&gt;25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;TOTALSUM&lt;/TD&gt;
&lt;TD width="50%"&gt;55&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;DIVIDED7days&lt;/TD&gt;
&lt;TD width="50%"&gt;7.85&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;datalines:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data have;
infile datalines dsd;
input ID :$1. COUNT;
datalines;
1,10
2,20
3,25

;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 20:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/711884#M219379</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-01-16T20:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sum up values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/711885#M219380</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
infile datalines dsd;
input ID :$1. COUNT;
datalines;
1,10
2,20
3,25
;

proc report data=have;
 columns id count weekly;
 define id/display;
 define count/analysis;
 define weekly/computed noprint;
 compute after;
  line @1 'Totalsum' @10 count.sum 8.2;
  weekly=count.sum/7;
  line @1 'Div7days' @10  weekly 8.2 ;
 endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV align="center"&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Report: Detailed and/or summarized report" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;COUNT&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD colspan="2" class="l linecontent"&gt;Totalsum&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;55.00&lt;BR /&gt;Div7days&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7.86&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 16 Jan 2021 20:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/711885#M219380</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-16T20:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sum up values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/711920#M219381</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dsd;
input ID :$1. COUNT;
datalines;
1,10
2,20
3,25
;
run;

proc sql;
create table want as 
select * from have
union all
select 'Total_sum' as ID,sum(count) as count  from have
union all
select 'DIVIDED7days' as ID,round(floor(sum(count)/7*100)/100,.01) as count from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/353472"&gt;@mmea&lt;/a&gt;&amp;nbsp;Alternate solution .&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jan 2021 06:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/711920#M219381</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2021-01-17T06:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sum up values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712090#M219454</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is it possible in the same proc report to add a statement that will take the total number of observations in one dataset and divide by the dataset used in this statement here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 12:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712090#M219454</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-01-18T12:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sum up values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712108#M219463</link>
      <description>&lt;P&gt;&lt;SPAN&gt;For total number of observations in one dataset, you can have that value in a macro variable and use that in proc report.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 13:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712108#M219463</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-18T13:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sum up values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712131#M219475</link>
      <description>&lt;P&gt;Okay - is there a way of doing so, im new to sas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sp a macro for the total number of observations in a dataset, and then i can divide that with the count_sum in the proc report?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 15:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712131#M219475</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-01-18T15:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sum up values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712147#M219485</link>
      <description>&lt;P&gt;Keep it simple. Get the count of nobs from some other dataset like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 select count(*) into :nobs
 from some_other_dataset;
quit;

%put nobs=&amp;amp;nobs; /*write the value of nobs in log*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then use the macro variable nobs whereever you want&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 16:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sum-up-values/m-p/712147#M219485</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-18T16:18:57Z</dc:date>
    </item>
  </channel>
</rss>

