Hello,
Here,s my data
creationdate creationtime filesize
2024-09-11 14:41:09 112252063
2024-10-31 15:59:49 109152507
2024-10-31 15:59:49 556
2024-11-15 10:14:06 111706769
2025-01-07 10:02:14 112484453
2025-01-28 14:26:40 112503907
2025-05-01 15:15:33 1934
data foldercontents2;
set foldercontents2;
crdate = input(trim(creationdate), mmddyy10.);
format crdate yymmdd10.;
run;
crdate is empty
Why do you use an informat with MDY order when the date strings are in YMD order?
The correct informat should be YYMMDD10.
Hi:
The INFORMAT you use in your INPUT. statement MUST match what is contained in the character value you want to convert to numeric. You are making the new numeric variable CRDATE by using the INPUT function to turn the string '2024-11-15', etc, into a numeric value representing a SAS date value. You told the INPUT function that CREATIONDATE should be transformed using the INFORMAT mmddyy10. I'm not entirely sure you need TRIM, depending on whether the original variable has trailing spaces. However, your CREATIONDATE character string looks like it is YYYY-MM-DD on all the rows you gave as an example. So I think you need this:
crdate = input(trim(creationdate), yymmdd10.);
Cynthia
Why do you use an informat with MDY order when the date strings are in YMD order?
The correct informat should be YYMMDD10.
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.