Currently I'm trying to import a .txt file to SAS, but I have one problem. The .txt I recieve has a columnthat looks this way
.......;2015/09/01 09:49;....
I need to import it as a date value not as a string. I've tryed many formats but none of them works correctly.
data aux;
infile "&LIBIN/&fichero" delimiter = ';' MISSOVER DSD lrecl=32767;
format fecha_mov .... ;
informat fecha_mov ....;
input
fecha_mov ;
run;
Thanks for the help in advanced,
Antonio,
答案 0 :(得分:0)
The informat anydtdtm. works for me. https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002605552.htm
data want;
infile cards dsd dlm=',';
informat dt anydtdtm.;
format dt datetime21.;
input dt;
cards;
2015/09/01 09:49
2015/09/01 08:49
2015/09/02 09:49
2015/09/05 09:49
;
run;
proc print;
run;
答案 1 :(得分:0)
我建议使用更具体的信息 - 如果源文件出现意外更改,则会消除anydtdtm.
格式错误地解释它的风险。如果您使用:
格式修饰符,则可以忽略时间部分,只需使用yymmdd10.
:
data want;
infile cards dsd dlm=',';
input dt :yymmdd10. another_var $5.;
format dt yymmdd10.;
cards;
2015/09/01 09:49,dummy
2015/09/01 08:49,dummy
2015/09/02 09:49,dummy
2015/09/05 09:49,dummy
;
run;
proc print;
run;
N.B。如果你不使用:
,那么SAS在开始读入下一个变量之前不会将行指针移动到下一个分隔符。