📄 date.sas
字号:
DATA dates;
INFILE DATALINES;
INPUT brthdate mmddyy10.;
DATALINES;
03/03/1971
02/14/1956
01/01/1960
;
run;
*比较以下两个关于日期的显示结果;
PROC PRINT;
VAR brthdate;
run;
PROC PRINT;
VAR brthdate;
FORMAT brthdate mmddyy10.;
run;
DATA age;
INFILE 'd:\data\tomdate.dat' ;
informat randdate mmddyy10.
brthdate mmddyy10.
date12 mmddyy10. ;
INPUT randdate brthdate date12;
agedays = randdate - brthdate ;
ageyrs = (randdate - brthdate)/365.25;
ageint = INT( (randdate - brthdate)/365.25);
agetoday= (TODAY() - brthdate)/365.25 ;
ageendst= (MDY(02,28,1992) - brthdate)/365.25;
daysv12 = date12 - randdate;
if ABS(daysv12 - 365) = . then window12 = .; else
if ABS(daysv12 - 365) < 31 then window12 = 1; else
if ABS(daysv12 - 365) >= 31 then window12 = 2;
yrrand = YEAR(randdate);
run;
PROC PRINT DATA=age (obs=10);
VAR brthdate randdate agedays ageyrs ageint agetoday;
TITLE '显示不加日期Format的数据';
RUN;
PROC PRINT DATA=age (obs=10);
VAR brthdate randdate agedays ageyrs ageint agetoday;
FORMAT brthdate mmddyy10. randdate mmddyy10.;
TITLE '显示加了日期Format的数据';
RUN;
PROC PRINT DATA=age (OBS=20);
VAR randdate date12 daysv12 window12;
FORMAT randdate date12 mmddyy8.;
TITLE 'Printing Days From Randomization to 1st Year Visit';
RUN;
PROC FREQ DATA=age;
TABLES yrrand;
TITLE 'Frequency Distribution of Year Randomized';
RUN;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -