Hi all,
I'm facing an issue with the DateTime format and pleas find below the code
{
DATA _TIME;
INFILE DATALINES;
INPUT CMS_DAT DATETIME26.;
FORMAT CMS_DAT DATETIME26.6;
CMS_DT = PUT(CMS_DAT,DATETIME30.6);
DATALINES;
22MAR2018:12:32:43.491538
06DEC2017:00:31:54.664700
03JAN2018:08:33:57.142454
17OCT2017:00:33:19.866942
2018-03-22-02.32.43.491538
28MAR2018:07:33:28.239593
;
RUN;
PROC PRINT DATA=_TIME;
RUN;
DATA _TIMEQ;
SET _TIME;
RESULT =TRIM(LEFT(PUT(DATEPART(CMS_DAT),YYMMDDD10.)||'-'||
PUT(TIMEPART(CMS_DAT),TIME15.6)));
RUN;
PROC PRINT DATA = _TIMEQ;
RUN;
}
and results are comming like
RESULT
2018-03-22-12:32:43.491538
2017-12-06- 0:31:54.664700
2018-01-03- 8:33:57.142454
2017-10-17- 0:33:19.866942
.- .
2018-03-28- 7:33:28.239593
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
after datepart all 0 values are missing
so kindly help out this senioro
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
and my expecting results should be like
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22MAR2018:12:32:43.491538
06DEC2017:(0)0:31:54.664700
03JAN2018:(0)8:33:57.142454
17OCT2017:(0)0:33:19.866942
.
28MAR2018:(0)7:33:28.239593
what ever i highleted with braghctes those are not comming in expexcted output
kindly give some solution for the above issue
Thanks & regards
rohit
Your expected result is exactly what you already have in CMS_DT (put with datetime26.6)
You probably want the TOD format and not the TIME format to preserve the leading zero.
871 data _null_; 872 time='09:00't; 873 put 'TIME ' time time15.6; 874 put 'TOD ' time tod15.6; 875 run; TIME 9:00:00.000000 TOD 09:00:00.000000
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.