楼主: Polaris008
8665 11

[问答] SAS计算年龄 [推广有奖]

11
ariman911 发表于 2013-6-3 21:51:19
SAS Example 2: Calculating a Person’s Age
You can calculate a person’s age by using three arguments in the YRDIF function. The third argument, basis, must have a value of AGE:
data _null_;
   sdate='16oct1998'd;
   edate='16feb2010'd;
   age=yrdif(sdate, edate, 'AGE');
   put age= 'years';
run;

12
wujianlan617 发表于 2013-6-4 14:41:37
Polaris008 发表于 2013-5-31 21:30
compress语句好像没起作用,age栏的格式还是没有变化。
15         data _null_;
16            age=compress(scan('05mar1962:00:00:00',1,':'));
17            c=floor((input('2012-10-31',yymmdd10.)-input(age,date9.))/365.25);
18            put c=;
19         run;

c=50

你看看这是我在日志里的结果,希望对你有帮助。

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-1 08:41