2

我有 csv 格式的数据,其中包含这种格式的特定时间戳字段:

'2009-07-30 20:50:19'

如何将其读入 SS 数据集?我一直在尝试这个,但没有成功。

             data filecontents;
             infile       "C:\es.txt" dlm=',' MISSOVER DSD firstobs=2 lrecl=32767 ;
             input  START_TIME :ANYDTDTM. 
             FORMAT START_TIME datetime.

谢谢。

4

1 回答 1

4

对我来说似乎很好。下面的代码适用于我的机器(9.3 TSM2)。你会发生什么?您是否只是在输入语句后缺少分号(您的示例代码是)?

data test;
infile "c:\temp\test.csv" dlm=',' missover;
input 
    dtvar :YMDDTTM.
    var1 $
    var2 $;
format dtvar DATETIME19.;
put dtvar= DATETIME19.;
run;

结果:

608  data test;
609  infile "c:\temp\test.csv" dlm=',' missover;
610  input
611      dtvar :YMDDTTM.
612      var1 $
613      var2 $;
614  format dtvar DATETIME19.;
615  put dtvar= DATETIME19.;
616  run;

NOTE: The infile "c:\temp\test.csv" is:
      Filename=c:\temp\test.csv,
      RECFM=V,LRECL=256,File Size (bytes)=31,
      Last Modified=20Nov2012:20:20:51,
      Create Time=20Nov2012:20:17:51

dtvar=30JUL2009:20:50:19
NOTE: 1 record was read from the infile "c:\temp\test.csv".
      The minimum record length was 29.
      The maximum record length was 29.
NOTE: The data set WORK.TEST has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds

对于它的价值,YMDDTTMw.d 是特定的信息(当然,ANYDTDTM. 也可以)。

于 2012-11-21T02:16:28.147 回答