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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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