织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

Comparison O欧博perators

时间:2025-11-14 11:55来源: 作者:admin 点击: 5 次
In the previous example, we used the less-than sign to make the comparison. We can use any of the standard comparison operators to make our comparison

In the previous example, we used the less-than sign to make the comparison. We can use any of the standard comparison operators to make our comparisons as long as we follow the syntax that SAS expects, which is:

Comparison

SAS syntax

Alternative SAS syntax


less than

 

<

 

LT

 

greater than

 

>

 

GT

 

less than or equal to

 

<=

 

LE

 

greater than or equal to

 

>=

 

GE

 

equal to

 

=

 

EQ

 

not equal to

 

^=

 

NE

 

equal to one of a list

 

in

 

IN

 

It doesn't really matter which of the two syntax choices you use. It's just a matter of preference. To convince yourself that you understand how to use the alternative SAS syntax though, replace the less-than sign (<) in the Example 5.1 program with the letters "LT" (or "lt"). Then, re-run   the SAS program and review the output from the PRINT procedure to see that the program indeed performs as expected.

Example 5.2

The following SAS program uses the IN operator to identify those students who scored a 98, 99, or 100 on their project score. That is, students whose p1 value equals either 98, 99, or 100 are assigned the value 'Excellent' for the project variable:

DATA grades; input name $ 1-15 e1 e2 e3 e4 p1 f1; if p1 in (98, 99, 100) then project = 'Excellent'; DATALINES; Alexander Smith 78 82 86 69 97 80 John Simon 88 72 86 . 100 85 Patricia Jones 98 92 92 99 99 93 Jack Benedict 54 63 71 49 82 69 Rene Porter 100 62 88 74 98 92 ; RUN; PROC PRINT data = grades; var name p1 project; RUN;

Launch and run   the SAS program and review the output from the PRINT procedure to convince yourself that the program performs as described.

NOTE! After being introduced to the comparison operators, students are often tempted to use the syntax EQ in an assignment statement. If you try it, you'll soon learn that SAS will hiccup at you. Assignment statements must always use the equal sign (=).

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-11-15 08:11 最后登录:2025-11-15 08:11
栏目列表
推荐内容