楼主: loyelimy
3924 6

[SAS] 【求助】弱问sas里面有没有函数可以求积 [推广有奖]

  • 0关注
  • 0粉丝

大专生

15%

还不是VIP/贵宾

-

威望
0 级
论坛币
795 个
通用积分
0
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
297 点
帖子
30
精华
0
在线时间
46 小时
注册时间
2009-3-1
最后登录
2018-12-19

楼主
loyelimy 发表于 2009-5-24 09:16:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
<p>就像sum求和一样,想求分类乘积,不知道如何实现。</p>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:有没有 如何实现 不知道 Sum 函数 SAS

回帖推荐

rdzr 发表于7楼  查看完整内容

6楼正解,偶学习了,这里似乎可以简化一下程序,让您见笑了:data dset;input x c;cards;-1   1-2   12    1.    1-2.5 20    21    2.    21    32    33    3;proc sql;select c, (-1)**sum((x<0&^missing(x)))*(sum((x=0))=0)*exp(sum(^missing(x))*avg(log(abs(x)))) as pr ...

jingju11 发表于6楼  查看完整内容

data dset; dset;input x c;cards;-1 1-2 1. 1-2.5 20 2;;-1 1-2 1. 1-2.5 20 2;proc sql;select (-1)**sum((x<0&^missing(x)))*(sum((x=0))=0)*exp(sum(^missing(x))*avg(log(abs(x)))) as productX from dset group by c; sql;select (-1)**sum((x<0&^missing(x)))*(sum((x=0))=0)*exp(sum(^missing(x))*avg(log(abs(x)))) as productX from dset group by c;select (-1)**sum((x<0&^missing( ...

rdzr 发表于5楼  查看完整内容

LZ,下面一下思路,请参考——注意:由于ln(ab)=ln(a)+ln(b),因此可将原数据取对数后再分类求和,然后再求出分类积,程序示意如下: data a; input x c @@; y=log(x);cards;2 1 3 1 4 1 5 2 6 2 7 2;proc means sum; class c; var y;run;运行结果如下:                       &nb ...

本帖被以下文库推荐

沙发
爱萌 发表于 2009-5-24 11:37:00
<p>oh, this is simple problem ,you can process your self</p>
最恨对我说谎或欺骗我的人

藤椅
jingju11 发表于 2009-5-25 11:54:00
proc sql;select (sum((x=0)))*exp(count(*)*avg(log(x))) as productX from dset(where=(x^=.));quit;

板凳
nkwilling 发表于 2009-5-25 12:22:00
<p>希望能正面回答别人的提问,别人不懂才问的,不管在你看来是否所谓的真简单。</p>

报纸
rdzr 发表于 2009-5-25 17:44:00
<p>LZ,下面一下思路,请参考——注意:由于ln(ab)=ln(a)+ln(b),因此可将原数据取对数后再分类求和,然后再求出分类积,程序示意如下:</p><p></p><p>&nbsp;data a;</p><p>&nbsp;input x c @@;</p><p>&nbsp;y=log(x);</p><p>cards;</p><p>2 1 3 1 4 1 5 2 6 2 7 2</p><p>;</p><p>proc means sum;</p><p>&nbsp;class c;</p><p>&nbsp;var y;</p><p>run;</p><p></p><p>运行结果如下:</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The SAS System&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16:56 Tuesday, May 25, 2009&nbsp; 15</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----------------------------------<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.1780538</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.3471075<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -----------------------------------<br/></p><p>然后,可以很容易地用 exp(3.1780538)=24, exp(5.3471075)=210 ,这就是 LZ 所需要的分类乘积结果。谢谢!</p>
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

地板
jingju11 发表于 2009-5-25 21:38:00
<b><font face="Courier New" color="#000080" size="2"><p>data<font face="Courier New" size="2"> dset;</font></p></font></b><font face="Courier New" size="2"> dset;</font><p><font face="Courier New" size="2">i</font><font face="Courier New" color="#0000ff" size="2">nput</font><font face="Courier New" size="2"> x c;</font></p><font face="Courier New" color="#0000ff" size="2"><p>cards<font face="Courier New" size="2">;<p>-1 1</p><p>-2 1</p><p>. 1</p><p>-2.5 2</p><p>0 2</p><p>;</p></font></p></font><font face="Courier New" size="2">;<p>-1 1</p><p>-2 1</p><p>. 1</p><p>-2.5 2</p><p>0 2</p><p>;</p></font><b><font face="Courier New" color="#000080" size="2"><p>proc<font face="Courier New" size="2">
                                </font><b><font face="Courier New" color="#000080" size="2">sql</font></b><font face="Courier New" size="2">;<p><font face="Courier New" color="#0000ff" size="2">select</font><font face="Courier New" size="2"> (-</font><b><font face="Courier New" color="#008080" size="2">1</font></b><font face="Courier New" size="2">)**sum((x&lt;</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">&amp;^missing(x)))*(sum((x=</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">))=</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">)*exp(sum(^missing(x))*avg(log(abs(x)))) </font><font face="Courier New" color="#0000ff" size="2">as</font><font face="Courier New" size="2"> productX <p><font face="Courier New" color="#0000ff" size="2">from</font><font face="Courier New" size="2"> dset </font><font face="Courier New" color="#0000ff" size="2">group</font><font face="Courier New" size="2">
                                                                </font><font face="Courier New" color="#0000ff" size="2">by</font><font face="Courier New" size="2"> c;</font></p></font></p></font></p></font></b><font face="Courier New" size="2">
        </font><b><font face="Courier New" color="#000080" size="2">sql</font></b><font face="Courier New" size="2">;<p><font face="Courier New" color="#0000ff" size="2">select</font><font face="Courier New" size="2"> (-</font><b><font face="Courier New" color="#008080" size="2">1</font></b><font face="Courier New" size="2">)**sum((x&lt;</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">&amp;^missing(x)))*(sum((x=</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">))=</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">)*exp(sum(^missing(x))*avg(log(abs(x)))) </font><font face="Courier New" color="#0000ff" size="2">as</font><font face="Courier New" size="2"> productX <p><font face="Courier New" color="#0000ff" size="2">from</font><font face="Courier New" size="2"> dset </font><font face="Courier New" color="#0000ff" size="2">group</font><font face="Courier New" size="2">
                                        </font><font face="Courier New" color="#0000ff" size="2">by</font><font face="Courier New" size="2"> c;</font></p></font></p></font><font face="Courier New" color="#0000ff" size="2">select</font><font face="Courier New" size="2"> (-</font><b><font face="Courier New" color="#008080" size="2">1</font></b><font face="Courier New" size="2">)**sum((x&lt;</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">&amp;^missing(x)))*(sum((x=</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">))=</font><b><font face="Courier New" color="#008080" size="2">0</font></b><font face="Courier New" size="2">)*exp(sum(^missing(x))*avg(log(abs(x)))) </font><font face="Courier New" color="#0000ff" size="2">as</font><font face="Courier New" size="2"> productX <p><font face="Courier New" color="#0000ff" size="2">from</font><font face="Courier New" size="2"> dset </font><font face="Courier New" color="#0000ff" size="2">group</font><font face="Courier New" size="2">
                        </font><font face="Courier New" color="#0000ff" size="2">by</font><font face="Courier New" size="2"> c;</font></p></font><font face="Courier New" color="#0000ff" size="2">from</font><font face="Courier New" size="2"> dset </font><font face="Courier New" color="#0000ff" size="2">group</font><font face="Courier New" size="2">
        </font><font face="Courier New" color="#0000ff" size="2">by</font><font face="Courier New" size="2"> c;</font><b><font face="Courier New" color="#000080" size="2"><p>quit<font face="Courier New" size="2">;</font></p></font></b><font face="Courier New" size="2">;</font><p><font face="Courier New" size="2">*just for fun;</font></p><p><font face="Courier New" size="2">*楼上的没有考虑0和负数 的情况;</font></p>
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

7楼
rdzr 发表于 2009-5-26 11:39:00
<p>6楼正解,偶学习了,这里似乎可以简化一下程序,让您见笑了:</p><p>data dset;<br/>input x c;<br/>cards;<br/>-1&nbsp;&nbsp; 1<br/>-2&nbsp;&nbsp; 1<br/>2&nbsp;&nbsp;&nbsp; 1<br/>.&nbsp;&nbsp;&nbsp; 1<br/>-2.5 2<br/>0&nbsp;&nbsp;&nbsp; 2<br/>1&nbsp;&nbsp;&nbsp; 2<br/>.&nbsp;&nbsp;&nbsp; 2<br/>1&nbsp;&nbsp;&nbsp; 3<br/>2&nbsp;&nbsp;&nbsp; 3<br/>3&nbsp;&nbsp;&nbsp; 3<br/>;<br/>proc sql;<br/>select c, (-1)**sum((x&lt;0&amp;^missing(x)))*(sum((x=0))=0)*exp(sum(^missing(x))*avg(log(abs(x)))) as productX <br/>from dset group by c;<br/>quit;</p><p>下面是运行的结果:</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;The SAS System&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 08:58 Wednesday, May 26, 2009&nbsp;&nbsp; 7</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6<br/></p>
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

您需要登录后才可以回帖 登录 | 我要注册

客服
GMT+8, 2026-12-4 19:27