<?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: base sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376359#M90338</link>
    <description>&lt;P&gt;I'm a fan of SQL for this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *, sum(marks) as total
from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another option is to calculate the mean in PROC MEANS and merge in the data:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset" target="_self"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Jul 2017 17:38:23 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-07-16T17:38:23Z</dc:date>
    <item>
      <title>Add overall total to the data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376353#M90335</link>
      <description>&lt;P&gt;Hi all can you Please solve my small problem&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input id name$ marks;&lt;BR /&gt;total+marks;&lt;BR /&gt;cards;&lt;BR /&gt;1 a 10&lt;BR /&gt;2 b 20&lt;BR /&gt;3 c 30&lt;BR /&gt;4 d 40&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;in the above the last observation of total will 100&lt;/P&gt;
&lt;P&gt;i want to make a new variable called V and put the last observation of total in every observation of V&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i dont &amp;nbsp;want to hardcore the value i want to make it dynamic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10351iB5DFDA3DF273D82F/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="s.PNG" title="s.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2017 18:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376353#M90335</guid>
      <dc:creator>shivamarrora0</dc:creator>
      <dc:date>2017-07-16T18:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376356#M90336</link>
      <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;PRE&gt;data have;
input id name$ marks;
total+marks;
cards;
1 a 10
2 b 20
3 c 30
4 d 40
;

data want;
  do until (eof1);
    set have end=eof1;
    v+marks;
  end;
  do until (eof2);
    set have end=eof2;
    output;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2017 17:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376356#M90336</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-16T17:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376359#M90338</link>
      <description>&lt;P&gt;I'm a fan of SQL for this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *, sum(marks) as total
from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another option is to calculate the mean in PROC MEANS and merge in the data:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset" target="_self"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2017 17:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376359#M90338</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-16T17:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376376#M90348</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i know it from proc sql but i want to do it from data step only&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2017 20:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/376376#M90348</guid>
      <dc:creator>shivamarrora0</dc:creator>
      <dc:date>2017-07-16T20:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/377190#M90556</link>
      <description>&lt;P&gt;CEO Art297&lt;/P&gt;&lt;P&gt;Thanks for your inputs.&lt;/P&gt;&lt;P&gt;I have used the same code from CEO Art297 &amp;nbsp;and slightly modified to get the expected output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Shiva,&lt;/P&gt;&lt;P&gt;Can you please check this code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ata have;&lt;BR /&gt;input id name$ marks;&lt;BR /&gt;total+marks;&lt;BR /&gt;cards;&lt;BR /&gt;1 a 10&lt;BR /&gt;2 b 20&lt;BR /&gt;3 c 30&lt;BR /&gt;4 d 40&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;do until (eof1);&lt;BR /&gt;set have end=eof1;&lt;BR /&gt;v+marks;&lt;BR /&gt;end;&lt;BR /&gt;do until (last.marks);&lt;BR /&gt;set have ;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/14092iDB41469257A70D2E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;</description>
      <pubDate>Wed, 19 Jul 2017 07:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/377190#M90556</guid>
      <dc:creator>vadday9</dc:creator>
      <dc:date>2017-07-19T07:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/377333#M90593</link>
      <description>&lt;P&gt;Why would you change the 2nd dow loop until condition? Yes, in this case it will produce the same result, but with a warning that the variable 'last.marks' has never been initialized.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And, if you included a 'by marks' statement in your revised code it would only produce one record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you read up on what a DOW loop is and how it works (see:&amp;nbsp;&lt;A href="https://www.google.ca/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=2&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0ahUKEwi1yJWywZXVAhVryoMKHSYVA1UQFggvMAE&amp;amp;url=http%3A%2F%2Fsupport.sas.com%2Fresources%2Fpapers%2Fproceedings09%2F038-2009.pdf&amp;amp;usg=AFQjCNEO9qKX1DUwx_xXL7Mn4obLWAP6KQ" target="_blank"&gt;https://www.google.ca/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=2&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0ahUKEwi1yJWywZXVAhVryoMKHSYVA1UQFggvMAE&amp;amp;url=http%3A%2F%2Fsupport.sas.com%2Fresources%2Fpapers%2Fproceedings09%2F038-2009.pdf&amp;amp;usg=AFQjCNEO9qKX1DUwx_xXL7Mn4obLWAP6KQ&lt;/A&gt; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 14:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-overall-total-to-the-data-set/m-p/377333#M90593</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-19T14:04:48Z</dc:date>
    </item>
  </channel>
</rss>

