Need Date formatting code while exporting

Reply
Occasional Contributor
Posts: 16

Need Date formatting code while exporting

Hi All,

I am working on the number of ticket bookings of a flight.I have the different number of bookings  in one day at different time points and I have written the below code.

proc sql;

create table new as

  select date,sum(TOTAL_BOOKINGS_IN_CABIN) as neww  from boo

  group by date;

quit;

When I export this dataset called "new", then I am not getting the date column as in the date format (mm/dd/yyyy).It is giving as

date

41235

41236

.........

and so on.

I want the date as:

date

04/04/2014

02/05/2014

...... and so on.


Can someone pls help me on this?


Thanks in advance.

Sandeep



Occasional Contributor
Posts: 5

Re: Need Date formatting code while exporting

data _null_;

a=41235;

put a  mmddyys10.;

run;

Occasional Contributor
Posts: 16

Re: Need Date formatting code while exporting

Hi Madam,

Thanks for the reply.I did not understand your code.The date has the format of : 04/04/2014...but when I export ,date format is different.

If I assign a=41235, then it's difficult to assign for all the values,right? Can you please elaborate your code?

Thank you,

Sandeep

Occasional Contributor
Posts: 5

Re: Need Date formatting code while exporting

First, I am sorry to tell you that I'm a Sir, and then I 'm wonder that where do you want to export? I can give you a example as follows:

data a;

a=1;

format a mmddyys10.;

run;

proc export outfile="C:\Users\Pactera\Desktop\test.txt" dbms=tab replace;

run;

And the results is as following:

捕获.PNG

So, you can see that the results' format is what you want.

Super User
Posts: 5,391

Re: Need Date formatting code while exporting

How do you export?

Data never sleeps
Super User
Posts: 9,878

Re: Need Date formatting code while exporting

Does your date have a format ?

proc sql;

create table new as

  select date format=mmddyy10. ,sum(TOTAL_BOOKINGS_IN_CABIN) as neww  from boo

  group by date;

quit;

Occasional Contributor
Posts: 16

Re: Need Date formatting code while exporting

Hi friend,

Thanks for the reply.

Yes,the date has the format of : 04/04/2014......

I tried your code but it didn't work.I was exporting through the menu driven option(manually).

Please let me know if i miss something.

Super User
Posts: 9,878

Re: Need Date formatting code while exporting

Export it to what ? CSV ,EXCEL ?

Super User
Posts: 9,878

Re: Need Date formatting code while exporting

If it didn't work out.

Try to change date into character type variable :

Does your date have a format ?

proc sql;

create table new as

  select '09'x||put(date,mmddyy10. -l)  as d  ,sum(TOTAL_BOOKINGS_IN_CABIN) as neww  from boo

  group by date;

quit;

Ask a Question
Discussion stats
  • 8 replies
  • 272 views
  • 0 likes
  • 4 in conversation