楼主: 一线天56
1382 1

有一个程序,不清楚IF...THEN...在PDV中的具体情况是咋样,请指导一下。 [推广有奖]

  • 3关注
  • 2粉丝

硕士生

44%

还不是VIP/贵宾

-

威望
0
论坛币
1203 个
通用积分
1.0000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
4465 点
帖子
112
精华
0
在线时间
148 小时
注册时间
2014-11-16
最后登录
2023-7-5

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

data perm.people (drop=type);

infile census;

retain Address;

input type $1. @;

if type='H' then input @3 address $15.;

if type='P';

input @3 Name $10. @13 Age 3. @16 Gender$1.;

run;

对于type='H'的某个记录,原文指出当遇到第二个if时,由于不满足条件,原话是Because the condition is not true, the remainingstatements are not executed and control returns to the top of the DATA step.The PDV is initialized but Address is retained.

为什么不是直接将PDV中的数据输出即执行呀?而是回到顶部重新读取了呢?

而当遇到type='P'即第二个条件满足后,原文说:Now the subsetting IF statement checksfor the condition type='P'. In this iteration, the condition is true, so thefinal INPUT statement reads the values for Name, Age, and Gender.Then the values in the program data vector are written as the first observation, and control returns to the top of the DATA step.

这个时候为什么说就可以将PDV中的数据作为第一个观测输出呢?


二维码

扫码加我 拉你入群

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

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

关键词:Then The PDV observation Statements Because address control returns 程序

回帖推荐

孤单的我们 发表于2楼  查看完整内容

IF condition; tests whether the condition is true. If it is true, then SAS continues processing the current observation; if it is not true, then SAS stops processing the observation, does not add it to the SAS data set, and returns to the top of the DATA step. 如果为真,则继续处理当前观测;如果为假,则停止处理当前观测,不写入数据集,并返回data步的开始。
沙发
孤单的我们 发表于 2016-7-18 13:52:50 |只看作者 |坛友微信交流群
IF condition;
tests whether the condition is true. If it is true, then SAS continues processing the current observation; if it is not true, then SAS stops processing the observation, does not add it to the SAS data set, and returns to the top of the DATA step.

如果为真,则继续处理当前观测;如果为假,则停止处理当前观测,不写入数据集,并返回data步的开始。

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-1 10:59