<?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: Geomean in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886214#M43347</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236411"&gt;@Daily1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a RETAIN statement for variable &lt;FONT face="courier new,courier"&gt;product&lt;/FONT&gt; to your DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;retain product;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or use PROC UNIVARIATE to compute the geometric mean and&amp;nbsp; then merge the result back to the initial dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=have noprint;
by id p_id;
var rel;
output out=gm geomean=Geo;
run;

data want;
merge have gm;
by id p_id;
if last.p_id; /* to obtain only one observation per BY group */ 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 Jul 2023 11:34:11 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2023-07-25T11:34:11Z</dc:date>
    <item>
      <title>Geomean</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886208#M43346</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create the initial dataset */
data have;
  input S_ID ID C_ID M_ID P_ID CUPRICE BPRICE rel;
  datalines;
1 497 48 110 4 50 47.87 104.4495509
1 498 51 113 4 10 8.6 116.2790698
1 498 52 115 4 10 8.87 112.7395716
1 498 54 114 4 120 117.77 101.8935213
1 503 147 238 4 200 198.6 100.7049345
1 516 62 135 4 200 198.6 100.7049345
1 520 30 104 4 10 7.98 125.3132832
1 528 38 106 4 15 12.77 117.4628035
;
run;

proc sort data=have;
  by ID P_ID;
run;

data group_geomean;
  set have;
  by ID P_ID;
  
  if first.P_ID then do;
    product = 1;
    count = 0;
  end;

  product = product * rel;
  count + 1;

  if last.P_ID then do;
    Geo = product ** (1/count);
    output;
  end;
run;

i want calculate geomean&amp;nbsp;base&amp;nbsp;on&amp;nbsp;ID P_ID&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE style="border-collapse: collapse; width: 48pt;" border="0" width="64" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="64" height="19" align="left" style="height: 14.4pt; width: 48pt;"&gt;Geo&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;104.4496&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;110.1306&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;110.1306&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;110.1306&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;100.7049&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;100.7049&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;125.3133&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;117.4628&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 10:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886208#M43346</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2023-07-25T10:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Geomean</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886214#M43347</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236411"&gt;@Daily1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a RETAIN statement for variable &lt;FONT face="courier new,courier"&gt;product&lt;/FONT&gt; to your DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;retain product;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or use PROC UNIVARIATE to compute the geometric mean and&amp;nbsp; then merge the result back to the initial dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=have noprint;
by id p_id;
var rel;
output out=gm geomean=Geo;
run;

data want;
merge have gm;
by id p_id;
if last.p_id; /* to obtain only one observation per BY group */ 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jul 2023 11:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886214#M43347</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-07-25T11:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Geomean</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886219#M43349</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This output create on excel . i need same result on sas eg&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daily1_0-1690285531252.png" style="width: 604px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86078i872031D5986D1934/image-dimensions/604x166?v=v2" width="604" height="166" role="button" title="Daily1_0-1690285531252.png" alt="Daily1_0-1690285531252.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 11:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886219#M43349</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2023-07-25T11:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Geomean</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886224#M43350</link>
      <description>&lt;P&gt;Then use the PROC UNIVARIATE approach and omit the subsetting IF statement (&lt;FONT face="courier new,courier"&gt;if last.p_id;&lt;/FONT&gt;) in the DATA step.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 11:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Geomean/m-p/886224#M43350</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-07-25T11:56:20Z</dc:date>
    </item>
  </channel>
</rss>

