BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zimcom
Pyrite | Level 9

 

Hello community,

 

I am using 'C_date_new = input(C_date,anydtdte20.);' to read in a date variable (saved as text field) with date value of '18/10/24', but after I read in, the date was converted to '2024-10-18', is there another way to read in the text date field and make the correct conversion?

 

Appreciate your help and thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

And why aren't you using 

 

date_new = input(C_date,yymmdd8.);

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

is this a formatting problem rather?

 


data w;
C_date='18/10/24';
date_new = input(C_date,anydtdte20.);
format date_new yymmdd8.;
run;
novinosrin
Tourmaline | Level 20

And why aren't you using 

 

date_new = input(C_date,yymmdd8.);
ballardw
Super User

@zimcom wrote:

 

Hello community,

 

I am using 'C_date_new = input(C_date,anydtdte20.);' to read in a date variable (saved as text field) with date value of '18/10/24', but after I read in, the date was converted to '2024-10-18', is there another way to read in the text date field and make the correct conversion?

 

Appreciate your help and thank you!


Are your values like '18/10/24' supposed to be YEAR Month Day? then you need to explicitly use a format that does that like yymmdds8.

ANYDTDTE has to guess when there is not an explicit 4 digit year and will usually assume that a YEAR is the last value generally.

 

And after the whole Y2K thing I have a lot of wonder why anyone is unsophisticated enough to start creating more issues by using two-digit years.

zimcom
Pyrite | Level 9

Thank you @ballardw!

Thank you @novinosrin!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 741 views
  • 1 like
  • 3 in conversation