Why informat is not working in SAS

2019-09-04 12:46发布

Tried various formats of date, but output do not reflects any date. What could be the issue?

data c;
input age gender income color$ doj$;
format doj date9.;
datalines;
19 1 14000 W 14/07/1988
45 2 45000 b 15/09/1956
34 2 56000 y 14/09/1967
33 1 45000 b 14/02/1956
;
run;

标签: sas informat
1条回答
做自己的国王
2楼-- · 2019-09-04 13:08

You are mixing things up a bit. The date formats are to be applied on numeric data, not on text data. So you should not read in doj as $ (text), but as a date (so a date informat).

Try DDMMYY10. for doj on your input statement:

data c;
    input age gender income color$ doj ddmmyy10.;
    format doj date9.;
    datalines;
    19 1 14000 W 14/07/1988
    45 2 45000 b 15/09/1956
    34 2 56000 y 14/09/1967
    33 1 45000 b 14/02/1956
    ;
run;
查看更多
登录 后发表回答