<?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: Product of variable by ID variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663594#M198118</link>
    <description>Manual is pretty straightforward.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by claim_id;&lt;BR /&gt;&lt;BR /&gt;retain total;&lt;BR /&gt;&lt;BR /&gt;if first.claim_id then total = value;&lt;BR /&gt;else total = total * value;&lt;BR /&gt;&lt;BR /&gt;if last.claim_id then output;&lt;BR /&gt;&lt;BR /&gt;run;</description>
    <pubDate>Fri, 19 Jun 2020 20:27:49 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-06-19T20:27:49Z</dc:date>
    <item>
      <title>Product of variable by ID variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663592#M198117</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 data have;
 input claim_id $ value;
 cards;
 3 2
 3 2
 4 5
 4 8.5
 4 2.3
 123 0
 123 1
 125 2
 125 0
 125 3
 ;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to get the product of the value for each claim_id to get the want dataset below. I was hoping proc summary had a product option but that doesn't seem to be the case&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 input claim_id $ value;
 cards;
 3 4
 4 97.75
 123 0
 125 0
 ;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 20:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663592#M198117</guid>
      <dc:creator>PeterBr</dc:creator>
      <dc:date>2020-06-19T20:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Product of variable by ID variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663594#M198118</link>
      <description>Manual is pretty straightforward.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by claim_id;&lt;BR /&gt;&lt;BR /&gt;retain total;&lt;BR /&gt;&lt;BR /&gt;if first.claim_id then total = value;&lt;BR /&gt;else total = total * value;&lt;BR /&gt;&lt;BR /&gt;if last.claim_id then output;&lt;BR /&gt;&lt;BR /&gt;run;</description>
      <pubDate>Fri, 19 Jun 2020 20:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663594#M198118</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-19T20:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Product of variable by ID variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663597#M198121</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
 input claim_id $ value;
 cards;
 3 2
 3 2
 4 5
 4 8.5
 4 2.3
 123 0
 123 1
 125 2
 125 0
 125 3
 ;
 run;

data want;
 _n_=1;
 do until(last.claim_id);
  set have;
  by claim_id notsorted;
  value=value*_n_;
  _n_=value;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;claim_id&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;value&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;4.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;97.75&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;123&lt;/TD&gt;
&lt;TD class="r data"&gt;0.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;125&lt;/TD&gt;
&lt;TD class="r data"&gt;0.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 19 Jun 2020 20:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663597#M198121</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-19T20:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Product of variable by ID variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663602#M198126</link>
      <description>&lt;P&gt;Works great too, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 20:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Product-of-variable-by-ID-variable/m-p/663602#M198126</guid>
      <dc:creator>PeterBr</dc:creator>
      <dc:date>2020-06-19T20:55:25Z</dc:date>
    </item>
  </channel>
</rss>

