BookmarkSubscribeRSS Feed
Sandeepkumar
Calcite | Level 5

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



8 REPLIES 8
mingfeng07
Fluorite | Level 6

data _null_;

a=41235;

put a  mmddyys10.;

run;

Sandeepkumar
Calcite | Level 5

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

mingfeng07
Fluorite | Level 6

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.

LinusH
Tourmaline | Level 20

How do you export?

Data never sleeps
Ksharp
Super User

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;

Sandeepkumar
Calcite | Level 5

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.

Ksharp
Super User

Export it to what ? CSV ,EXCEL ?

Ksharp
Super User

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2152 views
  • 0 likes
  • 4 in conversation