BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

Hi, I havea data format as such MMDDYYP10. (samples below), I'm trying to get the months out of the dat but in a MONNAME. format.

Have

Date

05.02.2012

06.14.2012

07.04.2012

I used

Date_A = Month (Date);

Format Date_A MONANME.  but this didn't quite work

Want

Date_B   

May 

June

July

5 REPLIES 5
Reeza
Super User

The monname format uses a date variable not a month variable.

so

date_a=date;

format date_a monname10.;

or

format date monname10.;

podarum
Quartz | Level 8

Thank you

podarum
Quartz | Level 8

Hi Reeza, when I export it to Excel the date_a doesn't come across as only Month , but as the whole date similar to date.  In SAS it shows correct, how I would like it to.

Reeza
Super User

You exported the data with proc export?

By definition SAS does not export formats to Excel using proc export.

Instead you can create a new variable using the put statement that will recode the data and then export.

data_a=put(date, monname10.);

AncaTilea
Pyrite | Level 9

Hi.

PROC EXPORT does not keep formats, but the ODS tagsets does.

Below is a sample code that will keep ALL your formats.

       ods listing close;
             ods tagsets.excelxp path = "&output_path." file="&data..xml"
             style=analysis      options(absolute_column_width='10,10,8,8,10,10,15,8,15,8,15,10,8,8,8,8,10,10,15,8,15,8,15,10,8,8,8,8,20' 
        sheet_label=' ');


        ods tagsets.excelxp options(sheet_name="sheetname");

             proc print noobs label data = &data.;
                 var your_variables;
             run;
        ods tagsets.excelxp close;
        ods listing;

Good luck!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 1721 views
  • 4 likes
  • 3 in conversation