I'm pulling data from a database to load into another database. The file spec I've been given says the date I need to provide be in yyyy/mm/dd hh:mm format.
The date field I'm pulling is in SQL Server and it's a datetime field, but from the SAS library side of things it shows as "Number". How can I have it export to my Excel export as a date, and in the yyyy/mm/dd hh:mm format? (e.g. 2019/04/01 00:00)
Hi @kevinharshads1 ,
Since SAS keeps dates/ datetimes as a number of days/seconds since January 1st 1960 I would start with adding proper format to the variable you have and then do the export to Excel, e.g.
proc format;
picture myDate (default=16)
other='%Y/%0m/%0d %0H:%0M' (datatype=datetime);
run;
data want;
set have;
format myVariableName myDate.;
run;
proc export data = want ...
All the best
Bart
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.