DATA Step, Macro, Functions and more

How Do You Insert a Title in PROC EXPORT to Excel/HTML?

Accepted Solution Solved
Reply
Contributor
Posts: 61
Accepted Solution

How Do You Insert a Title in PROC EXPORT to Excel/HTML?

I have a colleague who is trying to insert a title in a PROC EXPORT to Excel/HTML file.   Can someone direct me to the SAS documentation for this or give me exact code sample to do this?


Accepted Solutions
Solution
‎03-23-2012 09:56 PM
SAS Super FREQ
Posts: 8,744

Re: How Do You Insert a Title in PROC EXPORT to Excel/HTML?

Hi:

  Proc EXPORT is exporting data from SAS to Excel. Data does not have a title. Data does not have colors. Data does not have font settings.

  On the other hand, if you use ODS CSV or ODS HTML or ODS MSOFFICE2K or ODS TAGSETS.EXCELXP, then you are sending a REPORT from SAS to Excel. That report can be coded using a SAS procedure, such as PROC REPORT, PROC TABULATE, PROC FREQ, PROC MEANS, PROC PRINT, etc. With any SAS procedure, you can use a SAS TITLE statement and that TITLE statement will be inserted into the HTML (or XML) file and that title will show up inside the Excel worksheet when the file created by ODS is opened by Excel.

  So, when you are using PROC EXPORT, you are exporting DATA from SAS to Excel; but when you are using ODS, you are creating a REPORT file in such a way that Excel knows how to open and render the file created by ODS. Proc EXPORT creates a true, binary .XLS file in Excel proprietary format. ODS creates a markup language file (either HTML, or CSV or XML) that represents your procedure output "marked up" by the appropriate markup language tags or delimiters.

  Ever since Office 97, Excel can open and render HTML files. Beginning with Office 2000, Microsoft created its own "flavor" of HTML and that is the flavor of HTML that is created by ODS MSOFFICE2K. Then in Office 2003, Microsoft invented its own "flavor" of Spreadsheet Markup Language XML and that is the flavor of XML that is created by ODS TAGSETS.EXCELXP.

  The example code below  uses a SAS TITLE statement with ODS destinations.

cynthia

ods html file='c:\temp\test_title1.html' style=sasweb;

ods msoffice2k file='c:\temp\test_title2.html' style=sasweb;

ods csvall file='c:\temp\test_title3.csv';

ods tagsets.excelxp file='c:\temp\test_title4.xml' style=sasweb

    options(embedded_titles='yes');

proc print data=sashelp.shoes nooks; 

   title 'this is the title';

run;

ods _all_ close;

View solution in original post


All Replies
Solution
‎03-23-2012 09:56 PM
SAS Super FREQ
Posts: 8,744

Re: How Do You Insert a Title in PROC EXPORT to Excel/HTML?

Hi:

  Proc EXPORT is exporting data from SAS to Excel. Data does not have a title. Data does not have colors. Data does not have font settings.

  On the other hand, if you use ODS CSV or ODS HTML or ODS MSOFFICE2K or ODS TAGSETS.EXCELXP, then you are sending a REPORT from SAS to Excel. That report can be coded using a SAS procedure, such as PROC REPORT, PROC TABULATE, PROC FREQ, PROC MEANS, PROC PRINT, etc. With any SAS procedure, you can use a SAS TITLE statement and that TITLE statement will be inserted into the HTML (or XML) file and that title will show up inside the Excel worksheet when the file created by ODS is opened by Excel.

  So, when you are using PROC EXPORT, you are exporting DATA from SAS to Excel; but when you are using ODS, you are creating a REPORT file in such a way that Excel knows how to open and render the file created by ODS. Proc EXPORT creates a true, binary .XLS file in Excel proprietary format. ODS creates a markup language file (either HTML, or CSV or XML) that represents your procedure output "marked up" by the appropriate markup language tags or delimiters.

  Ever since Office 97, Excel can open and render HTML files. Beginning with Office 2000, Microsoft created its own "flavor" of HTML and that is the flavor of HTML that is created by ODS MSOFFICE2K. Then in Office 2003, Microsoft invented its own "flavor" of Spreadsheet Markup Language XML and that is the flavor of XML that is created by ODS TAGSETS.EXCELXP.

  The example code below  uses a SAS TITLE statement with ODS destinations.

cynthia

ods html file='c:\temp\test_title1.html' style=sasweb;

ods msoffice2k file='c:\temp\test_title2.html' style=sasweb;

ods csvall file='c:\temp\test_title3.csv';

ods tagsets.excelxp file='c:\temp\test_title4.xml' style=sasweb

    options(embedded_titles='yes');

proc print data=sashelp.shoes nooks; 

   title 'this is the title';

run;

ods _all_ close;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 4409 views
  • 0 likes
  • 2 in conversation