楼主: kosaac
1224 2

[问答] SAS中不后缀"then..."的IF指令,意义和产出? [推广有奖]

  • 12关注
  • 1粉丝

博士生

9%

还不是VIP/贵宾

-

威望
0
论坛币
89 个
通用积分
6.8449
学术水平
1 点
热心指数
0 点
信用等级
0 点
经验
5951 点
帖子
254
精华
0
在线时间
159 小时
注册时间
2011-8-24
最后登录
2022-11-19

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
SAS中不后缀"then..."的IF指令,其具体意义和产出是啥呢?什么情况下要这么写呢?请大神指点!谢谢~
以下是指令代码:
图片1.jpg
以下是该指令的输出,似乎if last.dept; 这句没有发挥特殊作用,那么如果不写这句呢?输出结果会有不同吗?请指点:
图片2.jpg

二维码

扫码加我 拉你入群

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

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

关键词:统计 工具 求助

回帖推荐

Cecilia_Xi 发表于2楼  查看完整内容

if last.byvar, 只保留byvar(你的code中为dept)的最后一个观测:即只保留根据dept sort后的最后一个观测。参考如下code
沙发
Cecilia_Xi 在职认证  发表于 2020-4-17 00:00:53 |只看作者 |坛友微信交流群
if last.byvar, 只保留byvar(你的code中为dept)的最后一个观测:即只保留根据dept sort后的最后一个观测。参考如下code
  1. proc sort data=Sashelp.Heart(keep=Smoking_Status Weight)
  2.           out=Heart;
  3.    by Smoking_Status;
  4. run;

  5. data Count;
  6.    set Heart;                 /* data are sorted by Smoking_Status */
  7.    BY Smoking_Status;         /* automatically creates indicator vars */
  8.    if FIRST.Smoking_Status then
  9.       Count = 0;              /* initialize Count at beginning of each BY group */
  10.    Count + 1;                 /* increment Count for each record */
  11.    if LAST.Smoking_Status;    /* output only the last record of each BY group */
  12. run;

  13. proc print data=Count noobs;
  14.    format Count comma10.;
  15.    var Smoking_Status Count;
  16. run;
复制代码


已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
kosaac + 5 + 1 + 1 + 1 谢谢~

总评分: 论坛币 + 5  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

藤椅
l1i2n3i4n5g 在职认证  发表于 2020-4-17 10:42:42 |只看作者 |坛友微信交流群
The subsetting IF statementcauses the DATA step to continue processing only those raw data recordsor those observations from a SAS data set that meet the conditionof the expression that is specified in the IF statement. That is,if the expression is true for the observation or record (its valueis neither 0 nor missing), SAS continues to execute statements inthe DATA step and includes the current observation in the data set.The resulting SAS data set or data sets contain a subset of the originalexternal file or SAS data set.

If the expression isfalse (its value is 0 or missing), no further statements are processedfor that observation or record, the current observation is not writtento the data set, and the remaining program statements in the DATAstep are not executed. SAS immediately returns to the beginning ofthe DATA step because the subsetting IF statement does not requireadditional statements to stop processing observations.
已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
kosaac + 2 + 1 + 1 + 1 谢谢~

总评分: 论坛币 + 2  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

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

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

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

GMT+8, 2024-5-4 01:39