I am trying to import a csv file with datetime variable in the form
2011-02-02T15:22 |
But when the data is imported, only date remains like this
2011-02-02 |
Any help to import the datetime variable correctly?
Thanks,
Copy the data step from the log (proc import writes the data step it creates to the log) and adapt the informat for the column in question.
Then re-run the data step.
Use the e8601dt informat, as in
data test;
string = "2011-02-02T15:22";
dtval = input(string,e8601dt19.);
format dtval datetime19.;
put dtval=;
run;
You can use that informat directly in the input statement.
Post the import code (into a {i}) so we can see how you are importing it.
Copy the data step from the log (proc import writes the data step it creates to the log) and adapt the informat for the column in question.
Then re-run the data step.
Thanks. it worked.
Yes, as @Kurt_Bremser has stated, use a datastep import and set the columns yourself. Proc import is a guessing procedure - i.e. it is guessing what your data is. Never a good idea.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.