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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

1 REPLY 1
Cynthia_sas
SAS Super FREQ

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 13829 views
  • 0 likes
  • 2 in conversation