You can create a custom picture format with proc format.
But personally, I would advise to follow the ISO standards and use one of the e8601 formats provided by SAS OOTB.
The documentation for the picture statement in proc format is found here: http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.3&docsetId=proc&docsetTarget=p0n990vq...
@FLINT wrote:
Please help me with some sample text.I want to convert 03AUG2018:18:09:18
to
03/08/2018 18:09 .this is one of the values in column
There is no "conversion". Display formats are only rules for how a value is displayed. And the value must be correct. To change a TEXT value you either 1) create an actual numeric datetime value and use an appropriate format or 2) Write lots of ugly code to parse and put pieces together. An INPUT with the correct INFORMAT and a Put statement would possibly be acceptable. Most of the time is really a much better idea to create a date or datetime variable as then there are many more options on manipulation and display.
proc format library=work; picture dtfixed low-high = '%0m/%0d/%Y %0H:%0M:%0S' (datatype=datetime) ; run; data _null_; x=input('15Feb2017:01:09:13',datetime18.); put x= dtfixed. x= dtfixed16.; run;
is one way. Note that the number of displayed characters, as with other formats can be set by specifying the width in the format statement. You chose whether to display the seconds or not, but the value is there.
If you really must use that stupid Micro$lop date time appearance. And comparisons do not use formatted values.
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.