通过示例学SAS(5)--条件语句

逻辑运算符如下

Logical Comparison       Memonic       Symbol
Equal to                          EQ              =
Not equal to                     NE          ^= or ~= or ¬=
Less than                         LT              <
Less than or equal to           LE             <=
Greater than                      GT              >
Greater than or equal to        GE             >=
Equal to one in a list             IN

下述代码将依年龄进行分组

data conditional;
     length Gender $ 1
              Quiz $ 2;
     input Age Gender Midterm Quiz FinalExam;
     if Age lt 20 then AgeGroup = 1;
     if Age ge 20 and Age lt 40 then AgeGroup = 2;
     if Age ge 40 and Age lt 60 then AgeGroup = 3;
     if Age ge 60 then AgeGroup = 4;
datalines;
21 M 80 B- 82
. F 90 A 93
35 M 87 B+ 85

48 F . . 76
59 F 95 A+ 97
15 M 88 . 93
67 F 97 A 91
. M 62 F 67
35 F 77 C- 77
49 M 59 C 81
;
title "Listing of CONDITIONAL";
proc print data=conditional noobs;
run;

posted on 2008-08-22 16:17  zgw21cn  阅读(1533)  评论(0编辑  收藏  举报

导航