BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cugel
Obsidian | Level 7
I would like to convert the date format ddmmmyyyy:hh:mm:ss to dd-mm-yyyy hh:mm:ss so European standard. 
I have been looking for a solution for some time but have not yet been able to find a clear example.
I work with SAS Data Integration Studio. Any help is appreciated

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The photograph makes it looks like you have defined something to be calculated as the value of the DATETIME() function.

If you want to instead define it as a string that looks the way you want then use this as the expression:

catx(' ',put(date(),ddmmyyd10.),put(time(),time8.))

But that will create a CHARACTER variable and not the NUMERIC variable your current expression is creating.

View solution in original post

15 REPLIES 15
PeterClemmensen
Tourmaline | Level 20

I don't know if it exists out-the-box. You can always roll out your own like this

 

proc format; 
  picture dtfmt (default=19)
    low - high = '0%d-0%m-%Y 0%H:0%M:0%S' (datatype=datetime)
  ;
run;

data _null_;
   dt = 0;
   put dt dtfmt.;
run;
Cugel
Obsidian | Level 7
Hello Peter,



Thanks for your response.

However, I work with the graphics side of SAS DIS.

To my knowledge, your solution cannot be applied here.

In the expression field I have included the datetime().

So now the datetime() must be displayed in dd-mm-yyyy hh: mm: ss.



Greetings Jos



[cid:image001.png@01D6EA82.C173AD00]


PeterClemmensen
Tourmaline | Level 20

I have no idea about SAS DIS 🙂

Cugel
Obsidian | Level 7
No problem Peter thanks for your response.


ballardw
Super User

@Cugel wrote:
Hello Peter,



Thanks for your response.

However, I work with the graphics side of SAS DIS.

To my knowledge, your solution cannot be applied here.

In the expression field I have included the datetime().

So now the datetime() must be displayed in dd-mm-yyyy hh: mm: ss.



Greetings Jos



[cid:image001.png@01D6EA82.C173AD00]



You might provide an explicit use case. If it is that DI specific then perhaps we should move this to the DI section such as Data Management in Solutions.

 

I know that some of the graphics don't like certain custom formats in other parts of SAS. Very few graphs that made much sense actually use datetime values directly because the text is so long it is either cumbersome or occupies too much graph space.

So there may be workarounds by providing other variables or label options.

 

Cugel
Obsidian | Level 7
Hi Kurt,

Thanks for your comment.

Do you have maybe an example for me of such a code statement.

There is no clear example in the DIS manual.



Options fmtsearch = (myformat library work);

myformat ???






Kurt_Bremser
Super User

The documentation contains examples.

See FORMAT Procedure, particularly the PICTURE Statement, and the FMTSEARCH= System Option.

The FMTSEARCH option lists the catalogs or libraries where SAS goes looking for defined formats (defined formats are stored as catalog entries). If only a single-level library name is supplied, SAS assumes that there is a catalog named FORMATS there.

Cugel
Obsidian | Level 7
Hi Kurt,

Thanks for tutorial tips. Will take some study hours in the evenings.

For now I have solved the problem as follows.



CAT(catx('-',put(DAY(DATEPART(DATETIME())),z2.)

,put( MONTH(DATEPART(DATETIME())),z2.)

,YEAR(DATEPART(DATETIME()))

),' ',

catx(':',put(HOUR(DATETIME()),z2.)

, put(MINUTE(DATETIME()),z2.)

))



The loading date 17JAN2021:21:22:00 then becomes 17-01-2021 21:22.



Maybe not so neat, but workable for the moment.




Cugel
Obsidian | Level 7

I would like to convert the date format ddmmmyyyy:hh:mm:ss to dd-mm-yyyy hh:mm:ss so European standard.
I have been looking for a solution for some time but have not yet been able to find a clear example.
I work with the graphics side of SAS Data Integration Studio.

Any help is appreciated.


TEST_JOB_EXAMPLE_LOADDATE.PNG

datetime() format is now ddmmmyyyy:hh:mm:ss and I would like dd-mm-yyyy hh:mm:ss (European standard).

ChrisNZ
Tourmaline | Level 20

> datetime() format is now ddmmmyyyy:hh:mm:ss

1. datetime() is not a format, it is a function

2. You have no format in place at the moment, so I don't see the conversion you are referring to:

I would like to convert the date format ddmmmyyyy:hh:mm:ss to dd-mm-yyyy hh:mm:ss so European standard.

3. You need to see the name of your custom-built format (see @PeterClemmensen 's reply) in the format box.

Cugel
Obsidian | Level 7
Hi Chris,



Thanks you for your explanation.

But where can I find the "format box".

Is it a setting that must be placed on the SAS server or is it a format that can be set locally.




Tom
Super User Tom
Super User

The photograph makes it looks like you have defined something to be calculated as the value of the DATETIME() function.

If you want to instead define it as a string that looks the way you want then use this as the expression:

catx(' ',put(date(),ddmmyyd10.),put(time(),time8.))

But that will create a CHARACTER variable and not the NUMERIC variable your current expression is creating.

Cugel
Obsidian | Level 7
Hi Tom,

Thanks for your comment.

I looked for the solution in the same direction and already formatted the datetime () as a string.

But your solution is more compact and neat.




SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 15 replies
  • 4786 views
  • 6 likes
  • 6 in conversation