How to separate date and time when combined and assign time with am and pm.
And also can you please write down the code.
/*** UNTESTED CODE ***/
data want;
infile "filename.txt";
input name $10. & datetime :ANYDTDTM16.;
date=datetpart(datetime);
time=timepart(datetime);
format date ddyymm8. time timeampm8.;
run;
Give us an example of your input data. Please specify in your reply whether or not the data is already in a SAS data set as numeric or character, and whether it is formatted. If the data is not in a SAS data set and has to be read in from some text file, please show us an example of such a date and time.
Also, please, we are trying to help you, and you can help us by providing a more specific subject line to your original question. The existing subject line "SAS query" could apply to any question about anything in SAS.
SIR HERE IS THE DATA SET
Mr. Manoj 18/02/2007:3:30
Mr. Jacob 19/02/2007:4:15
Mr.Anil 19/02/2007:13:00
Mr.Rathod 20/03/2007:14:30
Sir for the above data set can you explain how to separate data and time and assign time am/pm.
Thanks for your feedback i will change my subject.
@Sundeep_M wrote:
SIR HERE IS THE DATA SET
Mr. Manoj 18/02/2007:3:30
Mr. Jacob 19/02/2007:4:15
Mr.Anil 19/02/2007:13:00
Mr.Rathod 20/03/2007:14:30
Sir for the above data set can you explain how to separate data and time and assign time am/pm.
Thanks for your feedback i will change my subject.
Thank you, but is this a SAS data set, or text that has to be read in from some external file?
Also, we request that you change the subject line of the original post in this thread.
Sir this is a text that has to be read from external file
/*** UNTESTED CODE ***/
data want;
infile "filename.txt";
input name $10. & datetime :ANYDTDTM16.;
date=datetpart(datetime);
time=timepart(datetime);
format date ddyymm8. time timeampm8.;
run;
See my footnotes for hints on posting data in form of code.
Note that this is a website for helping people do their work, not doing their work for them. If you need someone to write your code, hire a consultant.
Work through the free Programming 1 course to have all the basics settled.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.