SAS 中if和where的区别

原文地址:SAS 中if和where的区别 作者:峰峦清逸

转自:http://www.dxyer.cn/yanyk/tag/sas-条件语句-if-where/

 

平时经常使用if和where,无意中查到百度知道中有一个帖子,讲解if和where,一目了然(原文http://zhidao.baidu.com/question/208729911.html):

data tmp;
  set SASHELP.workers(firstobs=10 obs=15);
  if ELECTRIC>260;
run;
proc print;run;

                                 Obs     DATE    ELECTRIC    MASONRY

                                  1     OCT77      278.6      288.7
                                  2     NOV77      276.2      286.2
                                  3     DEC77      274.6      276.7
                                  4     JAN78      262.1      234.3
输出4条记录。
解法2:
data tmp;
  set SASHELP.workers(firstobs=10 obs=15);
  where ELECTRIC>260;
run;
proc print;run;
                                 Obs     DATE    ELECTRIC    MASONRY

                                  1     MAY78      278.0      295.5
                                  2     JUN78      289.5      308.3
                                  3     JUL78      296.6      306.9
                                  4     AUG78      305.1      315.3
                                  5     SEP78      307.8      310.6
               

你可能感兴趣的:(SAS)