Hi everyone,
I have a data set (data_set11) where the format of a variable (Decision_Date) is: 26NOV2010:00:00:00.000.
I would like to change it to 2010/11/26 AND extract the month (11).
Thank you
The value example you display means the variable is likely a DATETIME variable unless it is character, in which formats won't help a lot.
If it is datetime, there are limited SAS supplied formats but E8601DA10. or E8601DN10. come closest depending on whther you want single digit months and days to appear with a leading 0. There will be - instead of /
Or convert it to an actual date as Decision_date= datepart(Decision_date);
If you want a new variable then
month=month(datepart(Decision_date)); If you converted it to a date as above then
month= month(Decision_date);
Hi Dominic,
If you want to change your date directly to month, this is the code.
data one;
input date:datetime22.;
Month_of_your_date=month(datepart(date));
datalines;
26NOV2010:00:00:00.000
;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.