- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Tags:
- European date format
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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]
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have no idea about SAS DIS 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can create a custom format in a code node, and define the FMTSEARCH ootion in the precode for your job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ???
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
datetime() format is now ddmmmyyyy:hh:mm:ss and I would like dd-mm-yyyy hh:mm:ss (European standard).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
> 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.