<?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 add the sum of a variable into the data set for every record in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427754#M281418</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/186799"&gt;@Sunny4&lt;/a&gt;&amp;nbsp;note that I've modified your subject line to be more descriptive of your question.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jan 2018 16:46:56 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-15T16:46:56Z</dc:date>
    <item>
      <title>How to add the sum of a variable into the data set for every record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427746#M281416</link>
      <description>&lt;P&gt;I have data&lt;/P&gt;
&lt;P&gt;id&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Required output is&lt;/P&gt;
&lt;P&gt;id&amp;nbsp; &amp;nbsp;id_1&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where 6= sum of id's&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 16:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427746#M281416</guid>
      <dc:creator>Sunny4</dc:creator>
      <dc:date>2018-01-15T16:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427752#M281417</link>
      <description>&lt;P&gt;Interesting idea to sum up ID's.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know about SQL, you can use Proc SQL to solve this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are for sure other ways using DATA Step programming or using a Proc such as MEANS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL sample:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards;
  input id;
cards;
1
2
3
;

proc sql;
  select
    id
    , (select sum(id) from have) as id_1
  from
    have
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For next time: please provide a better subject line for the post, so that we have more information already in the title.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Find More information here&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Getting-Started/How-to-get-fast-helpful-answers/ta-p/226133/jump-to/first-unread-message" target="_blank"&gt;https://communities.sas.com/t5/Getting-Started/How-to-get-fast-helpful-answers/ta-p/226133/jump-to/first-unread-message&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 16:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427752#M281417</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2018-01-15T16:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the sum of a variable into the data set for every record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427754#M281418</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/186799"&gt;@Sunny4&lt;/a&gt;&amp;nbsp;note that I've modified your subject line to be more descriptive of your question.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 16:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427754#M281418</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-15T16:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the sum of a variable into the data set for every record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427767#M281419</link>
      <description>&lt;P&gt;Here is one proc+datastep method:&lt;/P&gt;
&lt;PRE&gt;data have;
  input id;
  datalines;
1
2
3
;

proc summary data=have;
  var id;
  output out=sum (drop=_:) sum=id_1;
run;

data want;
  set have;
  if _n_ eq 1 then set sum;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 17:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427767#M281419</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-15T17:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to add the sum of a variable into the data set for every record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427888#M281420</link>
      <description>&lt;P&gt;And here's a single data step solution.&amp;nbsp; It's still two passes through the data, but it's a single step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have (in=firstpass)
      have (in=secondpass);
  if firstpass then sumid+id;
  if secondpass;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jan 2018 23:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-the-sum-of-a-variable-into-the-data-set-for-every/m-p/427888#M281420</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-01-15T23:48:26Z</dc:date>
    </item>
  </channel>
</rss>

