BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

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

1 ACCEPTED SOLUTION
2 REPLIES 2
Cynthia_sas
Diamond | Level 26

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 551 views
  • 3 likes
  • 3 in conversation