BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rajeshm
Quartz | Level 8
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                  

1 ACCEPTED SOLUTION

Accepted Solutions
rajeshm
Quartz | Level 8

you have given correct solution but i am merging. i posted a new question/thread.

thanks for your help.

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

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.

 

Capture.PNG

 

So, checking the same list, the DTDATE format is a date/time format that outputs dates as 01JAN20

 

Capture2.PNG

--
Paige Miller
rajeshm
Quartz | Level 8

/* 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. */

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
rajeshm
Quartz | Level 8

you have given correct solution but i am merging. i posted a new question/thread.

thanks for your help.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 828 views
  • 0 likes
  • 3 in conversation