Help using Base SAS procedures

Date to Month Format

Accepted Solution Solved
Reply
Regular Contributor
Posts: 240
Accepted Solution

Date to Month Format

The issue is I have a column with " On time" which displays 02/20/12  I used MONAME to  format to Month "Feb "which is great in my SAS table. The issue is when I export to excel it converts it back 02/20/12 . What can I do to keep the format of  Feb ? Thanks for your assitance


Accepted Solutions
Solution
‎02-27-2012 02:45 AM
Super User
Posts: 10,023

Date to Month Format

try something like

data all;

set all;

on_time_month=put(on_time,monname3.);

run;

Ksharp

View solution in original post


All Replies
Respected Advisor
Posts: 3,156

Re: Date to Month Format

You probably need to convert it into character. Excel will not recognize SAS format.

Edit: something like:

data _null_;

a=input ('2/20/12', mmddyy8.);

b=put(a,monname3.);

put a b;

run;

Regards,

Haikuo

PROC Star
Posts: 7,471

Date to Month Format

I agree we Haikuo.  Create a new variable to export.  e.g.:

data have;

  informat on_time mmddyy8.;

  input on_time;

  on_time_month=put(on_time,monname3.);

  cards;

02/20/12

03/14/12

;

Regular Contributor
Posts: 240

Date to Month Format

HI Art,

I've a table named 'All' it has 30 columns . Using your data step how would I tie it together  to convert  my date of 4000 entries  to reflect Month but keep the columns . I tried  rename my table to the data step  'Have' to ALL  an it removed the rest of the columns

Thanks again for your assitance in this matter

Solution
‎02-27-2012 02:45 AM
Super User
Posts: 10,023

Date to Month Format

try something like

data all;

set all;

on_time_month=put(on_time,monname3.);

run;

Ksharp

PROC Star
Posts: 7,471

Date to Month Format

The code that both Ksharp and I suggested would take care of it for all 4,000 of your records.  I'm not sure what you actually did, as you didn't post the code that you ran.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 282 views
  • 4 likes
  • 4 in conversation