全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
5038 5
2012-10-10
请教:如何比较数据集中某一列任何两行的值是否相等
二维码

扫码加我 拉你入群

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

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

全部回复
2012-10-10 11:39:19
不明白你说的什么意思啊
二维码

扫码加我 拉你入群

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

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

2012-10-10 15:16:29
拿EXCEL来举例,如比较单元格A(3,1)和A(6,1)值的大小,返回一个逻辑值,在SAS中如何比较?
二维码

扫码加我 拉你入群

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

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

2012-10-10 21:06:14
dataset 自己和自己 Cartesian join。比如说
DATA one;
        INPUT idx id;
        DATALINES;
        1 1
        2 2
        3 2
        ;
RUN;
proc sql;
        create table test as
        select a.idx as a_idx, a.id as a_id, b.idx as b_idx, b.id as b_id,
                        case when a.id = b.id then 'Y' else 'N' end as equal
        from one a, one b where a.idx ne b.idx;
quit;
从结果能够看到row2和row3的id是一样的。
二维码

扫码加我 拉你入群

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

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

2012-10-12 09:34:19
Here is an example. Please take look if it is what you want.

801  data t1;
802     retain x1-x3 0;
803     retain y1-y5 'c';
804     array x(3) ;
805     array y(5) ;
806
807     do i=1 to 5;
808        do j=1 to dim(x);
809           x[j]=ranuni(123);
810        end;
811        do j=1 to dim(y);
812           y[j]=byte( ceil(20*ranuni(123))+64);
813        end;
814        output;
815        if i=3 then output;
816      end;
817  run;

NOTE: The data set WORK.T1 has 6 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


818  proc print;run;

NOTE: There were 6 observations read from the data set WORK.T1.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


819  proc sort data=t1 out=nodup_t1  dupout=d nodup; by _all_; run;

NOTE: There were 6 observations read from the data set WORK.T1.
NOTE: 1 duplicate observations were deleted.
NOTE: The data set WORK.NODUP_T1 has 5 observations and 10 variables.
NOTE: The data set WORK.D has 1 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

二维码

扫码加我 拉你入群

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

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

2012-10-13 16:53:59
Thank you!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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