Current table
subjectid | start date | starttime |
1 | 23-Nov-19 | 1213 |
2 | 24-Nov-19 | 1914 |
Need to combine date and time into one
subjectid | start date | starttime | start_date_time |
1 | 23-Nov-19 | 1213 | 11/23/19 12:13 |
2 | 24-Nov-19 | 1914 | 11/24/19 19:14 |
I tried to concatenate but it is not a good approach
Please tell us if the variable start_date is a numeric or character variable.
Please tell us if the variable starttime is a numeric or character variable.
So date is numeric, while time is character? So you would have to convert the character string time into hours and minutes as numbers, which is what this code does.
data want;
set have;
datetime=dhms(start_date,input(substr(time,1,2),2.),input(substr(time,3,2),2.),0);
format datetime datetime16.;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.