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

Hi, how do I convert a date time value in this format (YYYY-MM-DD HH:MM:SS) into a numeric date? 

 

When I run the below code want_str only has a "."

 

Thank you for your help in advance! 

 

data have;
	str="2023-02-03 15:49:06";
	Want_str=input(str, mmddyy10.);
	format want_str mmddyy10.;
run;

Scooby3g_0-1682082772073.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Scooby3g,

 

Use the proper informat:

Want_str=input(str, yymmdd10.);

(Why do you use the suffix "str" for a numeric variable?)

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @Scooby3g,

 

Use the proper informat:

Want_str=input(str, yymmdd10.);

(Why do you use the suffix "str" for a numeric variable?)

Scooby3g
Obsidian | Level 7

Thank you  @FreelanceReinh !!!!!!

 

The word/acronym "Str" was just on top of my head at the moment so I just used it as an example variable name. 

 

Posting the data step for anyone who needs it in the future!

 

data have;
	str="2023-02-03 15:49:06";
	Want_str=input(str, yymmdd10.);
	format want_str mmddyy10.;
run;

 

 

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 671 views
  • 2 likes
  • 2 in conversation