1
votes

I have a comma delimited data set whose first 2 rows is like this:

1/13/2010 21:09,3.3
11/30/2010 7:33,7.2
....

In trying to read the data in SAS, I have done this data step below:

data myDataSet;
     infile      'sampleData.csv'    dlm=',';
     input     timestamp     :mmddyy16.     value;
run;

Now that the data is now a SAS data set, I try to view it by doing:

data viewData;
     set     myDataSet;
     format     timestamp     date9.;
run;
proc     print     data=viewData;
run;

I observed that the timestamp column output only contains the date and not with the time. I want the timestamp to be read and displayed in a format like "dd-mm-yyyy HH:MM:SS". How do I ensure that in reading the file, the informat is correctly specified and no component of the timestamp is lost?

1
Can you please give code line illustrations as to how to go about this particular problem? I have gone through the documentations but was not able to find direct answers.Tunde Awosanya

1 Answers

0
votes

MMDDYYw is a date informat, not a datetime informat - it only reads days and larger and ignores the time. It has a practical maximum length of 10 (although it allows up to 32) as a result.

You can use MDYAMPM. to read those two dates in, among other informats. That might be the ultimately correct informat, or it might not, depending on the totality of your data; several NLS specific informats might also work. See the SAS informat documentation for more details.