作者west1996 (焦了六年变脆了)
看板Statistics
标题Re: [问题] SAS资料处理
时间Tue Feb 24 15:07:13 2009
※ 引述《a15321 (a15321)》之铭言:
: ※ 引述《liton (欧吉桑留学生)》之铭言:
: : Proc Sql;
: : create table group as
: : select group, type
: : from source
: : where group in
: : (select group, count(distinct type) from source
把这一行的count(distinct type)拿掉
变成(select group from sourse
就行了
: : group by group
: : having count(distinct type)>1);
: : quit;
: : 你很多类似问题..
: : 建议你买本入门的SQL
: 感谢,但我跑出来是错误讯息 @@
: ERROR: A subquery cannot select more than one column.
: ERROR: A Composite expression (usually a subquery)
: is used incorrectly in an expression.
: 马上google恶补了一下一些基础
: 请问这段如果改成这样会是一样吗
: PROC SQL;
: CREATE TABLE new AS
: SELECT group, type, COUNT(DISTINCT type)
: FROM source
: GROUP by group
: HAVING COUNT(DISTINCT type)>1;
: quit;
你这样也行 甚至第三行不用加count(distinct type)也行 只是资料顺序会跑掉
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.109.40.59