全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
5638 3
2010-08-01
我刚开始没有加这么多变量,运行的很好,可是多winsorize了三了变量就这样了,怎么回事呢,大于小于号有什么问题吗,都是英文状态下输入的。

554  proc sql;
555     create table a_winsorize as select port3.stkcd,port3.ar,port3.year1,
556     case
557     when(e<e_p1) then e_p1
558     when(e>e_p99)  then e_p99
559     else e
560     end as e,
561     case
562     when(c<c_p1) then c_p1
563     when(c>c_p99)  then c_p99
564     else c
565     end as c,
566     case
567     when(tacc<tacc_p1) then tacc_p1
568     when(tacc>tacc_p99)  then tacc_p99
569     else tacc
570     end as tacc,
571     case
572     when(le<le_p1) then le_p1
573     when(le>le_p99)  then le_p99
574     else le
575     end as le,
576     case
577     when(lc<lc_p1) then lc_p1
578     when(lc>lc_p99)  then lc_p99
579     else lc
580     end as lc,
581     case
582     when(ltacc<ltacc_p1) then ltacc_p1
583     when(ltacc>ltacc_p99)  then ltacc_p99
584     else ltacc
585     end as ltacc
586     from port3, a_quant;
ERROR: Expression using less than  (<) has components that are of different data types.
ERROR: Expression using greater than (>) has components that are of different data types.
ERROR: Result of WHEN clause 3 is not the same data type as the preceding results.
ERROR: Expression using less than  (<) has components that are of different data types.
ERROR: Expression using greater than (>) has components that are of different data types.
ERROR: Result of WHEN clause 3 is not the same data type as the preceding results.
ERROR: Expression using less than  (<) has components that are of different data types.
ERROR: Expression using greater than (>) has components that are of different data types.
ERROR: Result of WHEN clause 3 is not the same data type as the preceding results.
ERROR: The following columns were not found in the contributing tables: lc_p1, lc_p99, le_p1, le_p99,
       ltacc_p1, ltacc_p99.
587     quit;
二维码

扫码加我 拉你入群

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

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

全部回复
2010-8-1 14:36:17
三个错误:
1。case when中用来做比较的变量类型不同,请楼主检查是否一个是字符型,一个是数值型,注:proc sql做判断时不比data step,值为数值的字符型变量做运算时不会做自动转换。因此请确保逻辑运算的双方都为同类型变量。

2。case when子句3,即else后的结果字段类型与之前的then后的结果字段类型不符,即满足不同条件输出的结果不为同类型,这是不允许的,一个字段只能有一种类型。

3。某些变量在原表中不存在。
二维码

扫码加我 拉你入群

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

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

2010-8-1 20:00:19
626  proc univariate data=port3 ;
627     var  e c tacc lc ltacc le;
628     output out=a_quant p1=c_p1 tacc_p1 e_p1 lc_p1 ltacc_p1 le_p1 p99=c_p99 tacc_p99 e_p99 lc_p99
628! ltacc_p99 le_p99;
629  run;

NOTE: The data set WORK.A_QUANT has 1 observations and 12 variables.
NOTE: PROCEDURE UNIVARIATE used:
      real time           0.39 seconds
      cpu time            0.15 seconds


630  proc sql;
631     create table a_winsorize as select port3.stkcd,port3.ar,port3.year1,
632     case
633     when(e<e_p1) then e_p1
634     when(e>e_p99)  then e_p99
635     else e
636     end as e,
637     case
638     when(c<c_p1) then c_p1
639     when(c>c_p99)  then c_p99
640     else c
641     end as c,
642     case
643     when(tacc<tacc_p1) then tacc_p1
644     when(tacc>tacc_p99)  then tacc_p99
645     else tacc
646     end as tacc,
647     case
648     when(le<le_p1) then le_p1
649     when(le>le_p99)  then le_p99
650     else le
651     end as le,
652     case
653     when(lc<lc_p1) then lc_p1
654     when(lc>lc_p99)  then lc_p99
655     else lc
656     end as lc,
657     case
658     when(ltacc<ltacc_p1) then ltacc_p1
659     when(ltacc>ltacc_p99)  then ltacc_p99
660     else ltacc
661     end as ltacc
662     from port3, a_quant;
NOTE: The execution of this query involves performing one or more Cartesian product joins that can      not be optimized.
NOTE: Table WORK.A_WINSORIZE created, with 13252 rows and 9 columns.
  quit;
NOTE: PROCEDURE SQL used:
      real time           0.07 seconds
      cpu time            0.03 seconds
我修改了下前面,不知这算
NOTE: The execution of this query involves performing one or more Cartesian product joins that can      not be optimized.
NOTE: Table WORK.A_WINSORIZE created, with 13252 rows and 9 columns.
  这句提示是什么意思啊
二维码

扫码加我 拉你入群

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

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

2010-8-1 21:25:37
为什么不用那个macro了?
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群