I have a comma delimtier file and a field coming in at 6/1/2016 12:00:00 AM. How do i read that in on my input step? I just want the date of 6/1/2016
Thank you
If you import the properly, with a datastep and infile, and you read that data as a date-time, then you already have the date. You can extract it using the function datepart(). Thus is fouy want a character version you would just add:
char_date=put(datepart(dt_var),date9.);
If you use the ANYDTDTE. informat it will read it and store just the date part as a date value.
Or use the ANYDTDTM. informat and it will create a datetime value. You could then use DTDATE. formar to just display the date. or use the DATEPART() function to extract the date.
I'm with @Tom on this. I read lots of files with that date (almost time) field as dates because the data source exposes data as date and time but the time values are invariate (all 12:00:00 AM for example). Why anyone lets "time" become part of something when it never changes continues to annoy me greately.
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.