公卫百科  > 所属分类  >  SAS   
[0] 评论[0] 编辑

SAS IF, IF-THEN and IF-THEN-ELSE Statements

Conditional statements (if-then statements, if-then-else statements) are often used to assign values to variables. Example:


data new;
input prefix age sex $;
if prefix=821 then city='auburn';
if age <30 then young=1;
else young=0; 公卫论坛
if age<30 and sex='f' then yw=1;
if age>80 or prefix='749' then nogood=1;
.....


The logical connectives AND and OR are used to create compound tests, as illustrated above.

A counterless do-loop can be used to have more complicated processing after an if-branch. Example: 公卫家园


if age<30 then do;
if income<20000 then cat=1;
if income>20000 and income <30000 then cat=2;
end;
....


The return statement can be used to branch to the bottom of the data step program.

Do-loops and if-then statements can be nested. 公卫家园

附件列表


0

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。

如果您认为本词条还有待完善,请 编辑

上一篇 SAS Infile Statement    下一篇 SAS Filename Statement

标签

暂无标签

同义词

暂无同义词