ods listing close; ods results off; ods csv file='/xxxx/Aug.csv' ; proc print data=final noobs; format xxdate mmddyy10.; run; ods csv close; ods results on; ods listing;
xxdate field inside sas is 02JAN2019:00:00:00(field is datetime20 format and informat)
ods with csv sheet should contain 02JAN2019
you have given correct solution but i am merging. i posted a new question/thread.
thanks for your help.
Since variable xxdate is a date/time variable, you can only use datetime formats.
MMDDYY10. is a date format, not a datetime format. (How do you know? See the list of date and time formats at https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=allprodslang&docsetTarget=syn..., where it says that MMDDYY is a date format. So you can't use this date format on your date/time values.
So, checking the same list, the DTDATE format is a date/time format that outputs dates as 01JAN20
/* mmdd2 02AUG2020:00:00:00 datetime20. in sas dataset tab */
proc sql ;
create table Deposits_DetailXX as
select
MMDD2 format=dtdate9.,
from tab;
quit;
when i exported deposits_detailxx , getting mdd2 as largenumber. what should i do to get date9. format?
/* datepart function with date9. is working fine. but would like to know otherways. */
The DATEPART function is the correct tool for extracting dates from datetimes. Use it.
The DATEPART function is the correct tool for extracting dates from datetimes. Use it.
format=DTDATE9. also works when I try it in PROC SQL, so there must be something else that @rajeshm is not doing properly.
If you want to know an important fact about the relationship of dates and datetimes, here's a hint: a day consists of 86400 seconds.
@rajeshm wrote:
/* mmdd2 02AUG2020:00:00:00 datetime20. in sas dataset tab */
proc sql ;
create table Deposits_DetailXX as
select
MMDD2 format=dtdate9.,
from tab;
quit;
when i exported deposits_detailxx , getting mdd2 as largenumber. what should i do to get date9. format?
/* datepart function with date9. is working fine. but would like to know otherways. */
Exported to Excel? I am guessing this from your other thread. These are details that should be mentioned. How are you doing the export? Show us that part of the code.
you have given correct solution but i am merging. i posted a new question/thread.
thanks for your help.
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.