BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

can i please get help on this,

 

wants to convert below character value to date value 

 

Have 

char_var=2015.09.19 /*sorry but this is character value that i ended up by pulling it out from long string)*/

 

want

date_var=09192015 /*want it as a date*/

 

 

thank you in advance,

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

date_Var=mdy(scan(char_var,2,'.')+0,scan(char_var,3,'.')+0,scan(char_var,1,'.')+0);

format date_Var mmddyy8.;

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

date_Var=mdy(scan(char_var,2,'.')+0,scan(char_var,3,'.')+0,scan(char_var,1,'.')+0);

format date_Var mmddyy8.;

--
Paige Miller
Astounding
PROC Star

While I can't test this at the moment, you should be able to read the character string directly:

 

date_var = input(char_var, yymmdd10.);

 

That will give you the proper date value.  For display purposes, choose the date format that you would like.  To match the result you originally asked for:

 

format date_var mmddyyn8.;

 

Good luck.

woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

 

 

Reeza
Super User
date_want=input(date_have, anydtdte10.);
format date_want date9.;

This works for me. 

woo
Lapis Lazuli | Level 10 woo
Lapis Lazuli | Level 10

Yes Reeza that worked, thanks

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 1032 views
  • 1 like
  • 4 in conversation