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.
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;
Post example data, in a data step so we can see the variable attributes. From your post, it is not clear if you have a SAS date variable or a string.
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 |
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;
what do you suggest for creating an excel file from SAS dataset?
Proc export or ODS EXCEL. I even wrote the code for one of those...
Thank you so much Reeza! 🙂
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/
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.
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.