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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 802 views
  • 0 likes
  • 4 in conversation