Hi everyone,
I created a report to be exported as an Excel spreadsheet. The report has three tabs with titles and contents. The title in the second sheet keeps moving to the third sheet. I tried many ways to fix that, but I was not successful. I have attached an image of the issue (First title on the top should be in the second sheet NOT in the third sheet) and the SAS code that I used to create the report.
Thank you in advance for any help.
Amaal
Move the statements
title;
footnote;
before the ODS OPTIONS statement that starts the new sheet.
@Hopes wrote:
Hi everyone,I forgot to mention that when I run the code, it generates the report without any problem. However, I coded the report in SAS to be shared with internal people via email, along with a link that allows them to access the report saved in an internal folder. When I click on the link, I see the issue with the title. I think it could be an Outlook issue rather than SAS, which is another potential cause. Here is an example of the SAS code for the email:
Since the code following the above has no Title statement you might need to tell us what part of the code shown contains your "title".
If you haven't worked with SAS very long you may not have learned that TITLE and FOOTNOTE statements persist in a given session until changed. So if a previous unrelated program has a TITLE "Some title text"; then that title will appear in all output following. You would use a simple TITLE; to clear all of the title text following.
Best practice when posting code is to paste the text into a text or code box opened on the forum using the </> or "running man" icon that appears above the message window. Code pasted into the main message window will be formatted by the forum software and may result in artifacts that change the behavior of the code when copy/pasted into a SAS session for testing. The box also helps visually separate the text discussion of the problem from the code. Log text should go into a text box as well.
I will be a bit pedantic and say that your first code does not actually show the code you ran, only the definition of a macro. Statements prior to the macro execution may be the cause.
It might also help to specifically state which "title" text you do not want to appear.
The commented out code in the macro including ODS PDF might indicate as well that you are generating a PDF or some other ODS destination output as well. At which point options like GTITLE/NOGTITLE and GFOOTNOTE/NOGFOOTNOTE might come into play.
The following sample code works for me where I used SASHELP data sets. The titles and footnotes appear correctly in the Excel file and when emailed. Note the options for sending the Excel file as an attachment are required per this SAS Note:
https://support.sas.com/kb/59/389.html
ods _all_ close;
/* Create Reports 1*/
options pageno=1 ps=45 ls=130 orientation=landscape date center number;
/*ods pdf notoc file="&output.\&SYND._&REPORT_TYPE._&LEVEL_JURISDICTION._&sysdate..pdf";*/
ods excel file="c:\temp\test.xlsx"
options(suppress_bylines="yes"
sheet_name="Alert_Case_Listing"
embedded_titles="yes"
embedded_footnotes="yes"
embed_titles_once="yes"
start_at="B3");
title1 height=22pt color=Black bold f=arial "Hospital Emergency Department (ED) &syndrome_text Alert Case Listing";
footnote2 h=1.0 f=arial color=Black "Reported by NYSDOH Electronic Syndromic Surveillance System (ESSS)" ;
proc report data=sashelp.class nowd headline headskip missing
style (report)= [cellspacing=1 borderwidth=1 bordercolor=black font_face=Arial background=white]
style (header) =[font_weight=bold font_size=4 just=center color=Black verticalalign=middle background=#8FBC8F]
style(column)=[font_size=1 fontfamily=Arial verticalalign=top] ;
compute after/ style={borderleftcolor=white borderrightcolor=white borderbottomcolor=white color=#2B382B};
line @0 "*All syndromes are defined by patient Chief Complaints and Diagnosis Codes.";
endcomp;
run;
Ods excel options (sheet_name="Daily_Counts");
title1 height=18pt color=Black bold f=arial "Hospital Emergency Department (ED) &syndrome_text Daily Syndrome Counts";
title2 f=arial h=1.0 "in the past 15 days at &LEVEL_JURISDICTION level" ;
footnote1
h=1.1 f=arial c='pink' "Pink" h=1.1 f=arial c='black' " - C1 Signal; "
h=1.1 f=arial c='dark yellow' "Yellow" h=1.1 f=arial c='black' " - C2 Signal; "
h=1.1 f=arial c='red' "Red" h=1.1 f=arial c='black' " - C1C2 Signal ";
footnote2 h=1.0 f=arial color=black "Reported by NYSDOH Electronic Syndromic Surveillance System (ESSS)" ;
proc report data=sashelp.cars(obs=10) nowd headline headskip missing
style (report)= [cellspacing=1 borderwidth=1 bordercolor=black font_face=Arial background=white]
style (header) =[font_weight=bold font_size=4 just=center color=Black verticalalign=middle background=#8FBC8F]
style(column)=[font_size=1 fontfamily=Arial verticalalign=top] ;
run ;
Ods excel options (sheet_name="Syndrome_Graphs"
sheet_interval="None");
title;
footnote;
data text;
length title $100;
title="Short-term and Long-term Graphs for Alerted &syndrome_text Syndrome"; output;
run;
proc report data=text nowd noheader
style(report)=[rules=none frame=void outputwidth=50% cellspacing=0 borderwidth=0 background=white];;
column title;
define title / style={just=c font_weight=bold font_size=18pt verticalalign=middle color=black cellspacing=0};
run;
/*ODS PDF startpage=no;*/
ods graphics / reset=all height=3in width=10in;
/* short-term graph */
proc sgplot data=sashelp.class;
vbar age;
run;
footnote2 h=1.0 f=arial color=black "Reported by NYSDOH Electronic Syndromic Surveillance System (ESSS)" ;
/* long-term graph */
proc sgplot data=sashelp.class;
vbar sex;
run;
ods excel options(sheet_interval="now");
/*ods pdf close;*/
ods _all_ close;
ods listing;
filename mymail email
to="first.last@yahoo.com"
subject="test message"
attach=("c:\temp\test.xlsx"
content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" lrecl=32000);
data _null_;
file mymail;
put "ODS Excel Test";
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.