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/
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.