- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
is there any thing like day month or month day formats like the MMYYw.
Am looking for something like DDMMw. or MMDDw.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Anita_n wrote:
Hello,
is there any thing like day month or month day formats like the MMYYw.
Am looking for something like DDMMw. or MMDDw.
If you find that you cannot get what you want with any of the existing SAS formats you can use Proc Format with the Picture statement to create one of your own for dates, times or date times.
You get an MMDD using the MMDDYY4. but an example for DDMM
proc format; picture ddmm low-high ='%0D%0m' (datatype=date) ; run; data example; date=today(); run; proc print data=example; format date ddmm.; run;
The directives in the Picture statement, those things with %, are used to indicate the specific part of a date, time or datetime value. They are very case sensitive: %m is month, %M is minute . You want to use single quotes to avoid messages from the macro processor. The 0 forces always showing 2 digits for month and day with 01 to 09. Other characters in the picture are displayed literally. The datatype is used to tell SAS which type of value is expected so the directives are applied correctly when the value type matches.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ballardw @PeterClemmensen Thanks for that, it's amazing what one can learn from you guys. I realised I did not explain my question correctly. What I really wanted is , if I have two date variables and I find for example the difference between the dates in days
data have;format date1 date2 ddmmyy10.;date1='30dec2000'd;date2=today();var3=intck("day",date1, date2);run;*var3 should be displayed like 10months 5days or 2years 6months 5days;
I used day here because some results are less than 30days and might be displayed as 0. I want the the result of var3 to display the above results in days if the value of var3 is less than 30 but if the value is above 30, it should display something like 1month 3days, 12months 15days ......................
I don't really know if this is possible. This is to avoid having values like 11555 days, where the reader will first have to convert it to months. I will appreciate any help
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use case for verbiage like 1 month, 3 days? By use case I mean "how is this value to actually be used in other processes"?
Since your example dates of 30Dec2000 and today, 08Mar2023 or so, means there are about 267 months why is that of much use? People still need to convert that to something like years/months/days to make much sense.
@Anita_n wrote:
@ballardw @PeterClemmensen Thanks for that, it's amazing what one can learn from you guys. I realised I did not explain my question correctly. What I really wanted is , if I have two date variables and I find for example the difference between the dates in days
data have;format date1 date2 ddmmyy10.;date1='30dec2000'd;date2=today();var3=intck("day",date1, date2);run;*var3 should be displayed like 10months 5days or 2years 6months 5days;
I used day here because some results are less than 30days and might be displayed as 0. I want the the result of var3 to display the above results in days if the value of var3 is less than 30 but if the value is above 30, it should display something like 1month 3days, 12months 15days ......................
I don't really know if this is possible. This is to avoid having values like 11555 days, where the reader will first have to convert it to months. I will appreciate any help