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

Hi There, 

 

Have a dataset and want to split the date column to only contain the Date and create another column that has the time.

Currently, it is a character variable  and 03/17/2021,11:00am

 

I need it to be split as

Date                      Time

03/17/2021             11:00am

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
konvickt
Fluorite | Level 6
Hi Reeza, am getting a syntax error on time asking for format when I put in time_sas=input(time,time)
Error expecting a format name
Error Syntax error, statement will be ingnored

View solution in original post

4 REPLIES 4
Reeza
Super User
SCAN()

date =scan(originalVar, 1, ",");
time = scan(originalVar, 2, ",");

date_sas = input(date, mmddyy10.);
time_sas = input(time, time.);
format date_sas mmddyy10. time_sas time8.;
konvickt
Fluorite | Level 6

Thank you so much for the reply. Will give it a try 

konvickt
Fluorite | Level 6
Hi Reeza, am getting a syntax error on time asking for format when I put in time_sas=input(time,time)
Error expecting a format name
Error Syntax error, statement will be ingnored
Reeza
Super User
For starters you missed the period, it is required. It may not be the correct informat either, see the informat documentation to one that matches your current format.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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