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

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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