BookmarkSubscribeRSS Feed
AK100
Pyrite | Level 9

This is what I have:

AK100_0-1612961250835.png

I want to concatenate them all to 1 DATETIME format. How can that be done in a fast way?

 

 

 

7 REPLIES 7
PaigeMiller
Diamond | Level 26

You can use the MDY function to get a SAS date.


Then you can use the DHMS function to turn that date, plus hour minute second into a SAS datetime value.

--
Paige Miller
AK100
Pyrite | Level 9
Done that but got empty values back?
PaigeMiller
Diamond | Level 26

@AK100 wrote:
Done that but got empty values back?

Did what? Show us your code

--
Paige Miller
PeterClemmensen
Tourmaline | Level 20

See if you can use this as a template

 

data have;
input Year Month Day Hour Minute Second;
datalines;
2020 9 7 0 0 0
;

data want;
   set have;
   date = mdy(Month, Day, Year);
   datetime = dhms(date, Hour, Minute, Second);
   format date ddmmyy10. datetime datetime20.;
run; 

 

AK100
Pyrite | Level 9

Got This back, No DATALINES or INFILE statement.. Probably because I have this:

 

data work.merged_table;
input Year Month Day Hour Minute Second; 
;

data want;
   set work.merged_table;
   date = mdy(Month, Day, Year );
   datetime = dhms(date, Hour, Minute, Second);
   format date ddmmyy10. datetime datetime20.;
run; 

 

Kurt_Bremser
Super User

ALWAYS

supply example data in a data step with datalines, if you expect quick responses with a working suggestion.

A picture cannot be tested against, and we have NO IDEA AT ALL how your data really looks like.

Since the suggested code does work, the issue has to be your data.

PaigeMiller
Diamond | Level 26

@AK100 wrote:

Got This back, No DATALINES or INFILE statement.. Probably because I have this:


If you program work.merged_table as you did, it will be an empty data set. So, this is most likely the first problem you have.

--
Paige Miller

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!

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
  • 7 replies
  • 2535 views
  • 0 likes
  • 4 in conversation