<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Byval in header and Excel tab in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480048#M21314</link>
    <description>&lt;P&gt;Generally if the variable is numeric and you want to display text such as "January" then you need to have a format and apply it to the variable. Such as:&lt;/P&gt;
&lt;PRE&gt;proc format;
value mo
1='January'
2='February'
/* follow the pattern to*/
12='December'
;
run;&lt;/PRE&gt;
&lt;P&gt;and add: Format mo mo.; /* the second with the period is the name of the format*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to the proc report code. The by line would then read "MO=July".&lt;/P&gt;
&lt;P&gt;If add a label to the MO variable such as: Label mo='Month'; then the by line would read "Month=July".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't spend a lot of time worrying over tab names in Excel so I'm not sure if that will help but as a minimum since your last proc doesn't have a by variable you likely need to insert an additional ODS EXCEL options(sheet_name='something'); to set the name for that one.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jul 2018 19:42:40 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-07-20T19:42:40Z</dc:date>
    <item>
      <title>Byval in header and Excel tab</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480019#M21311</link>
      <description>&lt;P&gt;I have an excel report that I need to automate via SAS. Once exported, the report should have a tab for every month where data exists. The tab and header should indicate the month &lt;STRONG&gt;name&lt;/STRONG&gt;. Currently I have everything working except the month name. The report currently displays the month number instead. Below is my current SAS Code and a screenshot of the current output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro get_report();
	ods excel file='/prd/saucgo/reporting/summary/output/Monthly_Schedule.xlsx' 
	options(sheet_name='#byvar' /*'#byval1'*/ embedded_titles='yes' embedded_footnotes='yes'
		 tab_color='purple' start_at='2,4' frozen_headers='yes'
		 title_footnote_nobreak='yes' autofilter='1-10' absolute_column_width='16');
	title 'Monthly Schedule' ;
/*	footnote 'This footnote will appear in the worksheet';*/

	proc report data=Monthly_Schedule;
		by Mo;
		column Origin Destination Flight_Number	Depart_Time	Arrival_Time Aircraft Start_Date End_Date DOW_Ops Group;
		define Flight_Number / display 'Flight#';
		define SCH_AC_DPRT_TIM  / display 'Depart_Time';
		define SCH_AC_ARR_TIM / display 'Arrival_Time';
		define Yr / group;
		define Mo / group;
	run;

	proc report data=_Mth_Schd;
		column sch_dprt_stn_cd sch_arr_stn_cd LegStartDte LegEndDte Body;
		define sch_dprt_stn_cd / display 'Departure';
		define sch_arr_stn_cd / display 'Arrival';
		define LegStartDte / display 'Leg Start Date';
		define LegEndDte / display 'Leg End Date';
		ods excel close;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MonthlySchedule.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21892i0A56AFD629FD65BB/image-size/large?v=v2&amp;amp;px=999" role="button" title="MonthlySchedule.JPG" alt="MonthlySchedule.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 18:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480019#M21311</guid>
      <dc:creator>abcrandy</dc:creator>
      <dc:date>2018-07-20T18:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Byval in header and Excel tab</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480048#M21314</link>
      <description>&lt;P&gt;Generally if the variable is numeric and you want to display text such as "January" then you need to have a format and apply it to the variable. Such as:&lt;/P&gt;
&lt;PRE&gt;proc format;
value mo
1='January'
2='February'
/* follow the pattern to*/
12='December'
;
run;&lt;/PRE&gt;
&lt;P&gt;and add: Format mo mo.; /* the second with the period is the name of the format*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to the proc report code. The by line would then read "MO=July".&lt;/P&gt;
&lt;P&gt;If add a label to the MO variable such as: Label mo='Month'; then the by line would read "Month=July".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't spend a lot of time worrying over tab names in Excel so I'm not sure if that will help but as a minimum since your last proc doesn't have a by variable you likely need to insert an additional ODS EXCEL options(sheet_name='something'); to set the name for that one.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 19:42:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480048#M21314</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-20T19:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: Byval in header and Excel tab</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480062#M21317</link>
      <description>&lt;P&gt;Thanks &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_self"&gt;&lt;SPAN class="login-bold"&gt;ballardw&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;. That worked like a charm! One last thing. How do I remove the "MO=" to only show the month name?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 20:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480062#M21317</guid>
      <dc:creator>abcrandy</dc:creator>
      <dc:date>2018-07-20T20:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Byval in header and Excel tab</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480070#M21318</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179109"&gt;@abcrandy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_self"&gt;&lt;SPAN class="login-bold"&gt;ballardw&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;. That worked like a charm! One last thing. How do I remove the "MO=" to only show the month name?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Easiest might be an additional title statement coupled with the nobyline option.&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class
          out=work.class;
   by sex;
run;

options nobyline;
title ' #byval(sex) ' ;
proc print data=work.class noobs;
  by sex;
  var name;
run; title;

options byline;&lt;/PRE&gt;
&lt;P&gt;use a title with a higher number such as title2 than the ones you are currently using to make sure that if follows your existing one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't forget to reset the option byline to return to the default behavior.&lt;/P&gt;
&lt;P&gt;the last title statement clears the title so you don't get that title on other output.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 20:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Byval-in-header-and-Excel-tab/m-p/480070#M21318</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-20T20:55:46Z</dc:date>
    </item>
  </channel>
</rss>

