BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Juli13
Fluorite | Level 6

I have a SAS dataset with a variable named cars in YYMM7. format and I want to convert it to MMDDYY10. format. Please suggest the complete code to do so. This is what i have so far-


%let path=C:\Users\AB\Documents\My SAS Files\9.4; 
libname abcd "&path";
ods HTML file="C:\Users\AB\Documents\My SAS Files\9.4\line.xls";
proc print data=abcd.line;
run;
ods HTML close;

 

I am using a sas dataset to create an excel file and I need the date of the variable cars changed from YYMM7. to MMDDYY10. format.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You shouldn't use ODS HTML to create an Excel file, unless you're on really old versions of SAS IMO.

 

%let path=C:\Users\AB\Documents\My SAS Files\9.4; 

libname abcd "&path";

ods Excel file="C:\Users\AB\Documents\My SAS Files\9.4\line.xlsx";

proc print data=abcd.line;

format cars mmddyy10.;
run; ods excel close;

View solution in original post

9 REPLIES 9
Juli13
Fluorite | Level 6
2017M06
2015M10
2014M06
2014M03
2014M03
2014M06

above is an example of the various observations in the variable  that I want to change to the following format-

7/1/2012
10/1/2013
10/1/2013
10/1/2012
4/1/2012
Reeza
Super User

You shouldn't use ODS HTML to create an Excel file, unless you're on really old versions of SAS IMO.

 

%let path=C:\Users\AB\Documents\My SAS Files\9.4; 

libname abcd "&path";

ods Excel file="C:\Users\AB\Documents\My SAS Files\9.4\line.xlsx";

proc print data=abcd.line;

format cars mmddyy10.;
run; ods excel close;
Juli13
Fluorite | Level 6

what do you suggest for creating an excel file from SAS dataset?

Reeza
Super User

Proc export or ODS EXCEL. I even wrote the code for one of those...

Juli13
Fluorite | Level 6

Thank you so much Reeza! 🙂

 

Juli13
Fluorite | Level 6
what is the code for proc export?
Reeza
Super User

Here's an old blog post that has sample code and several methods.

http://blogs.sas.com/content/sasdummy/2012/02/11/export-excel-methods/

 

Juli13
Fluorite | Level 6
Thanks Reeza! Incredibly helpful!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 9 replies
  • 1916 views
  • 0 likes
  • 3 in conversation