Is the only way to read in a date that comes through with varying lengths for the month is to read it in as a string first and then change it to a date once it is read in?
Thanks,
Can you post an example of what your values are to avoid assumptions
@pchappus wrote:
Is the only way to read in a date that comes through with varying lengths for the month is to read it in as a string first and then change it to a date once it is read in?
Thanks,
Post an example please
@pchappus wrote:
Is the only way to read in a date that comes through with varying lengths for the month is to read it in as a string first and then change it to a date once it is read in?
Thanks,
Nope.
I read a fair amount of data from CSV files with a data step that usually contains one or more date variables. Unless by "varying lengths for the month" you mean Jan Janu etc then the mmddyy10. informat handles most variations nicely except for a 6 digit without / delimiters.
data example; informat date mmddyy10.; input date; format date date9.; datalines; 01/01/2019 1/1/2019 01/1/2019 1/01/2019 01012019 1012019 112019 ; run;
All except the last value will return 01JAN2019. The last assumes the year is only 2 digits because that 6 digit is subject to way to many interpretations.
I actually ended up getting it to work. I used MMDDYY8. and it seemed to realized if the month was a Jan-Sept and added the leading zero.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.