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

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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