<?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: Using across in PROC REPORT with nesting and labels in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958304#M83900</link>
    <description>&lt;P&gt;Hi Tom:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the full code. Sorry, my bad. I was planning to color code and annotate in the screen shot but then got called away and so I just posted it without much extra commenting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fakedata;
  infile datalines dlm=',';
  input Col1 $ Col2 $ Treatment Location Value;
datalines;
A, A, 1, 1, 1
A, A, 1, 2, 2
A, A, 2, 1, 3
A, A, 2, 2, 4
A, B, 1, 1, 5
A, B, 1, 2, 6
A, B, 2, 1, 7
A, B, 2, 2, 8
;
run;

** need to assign values to the macro variables for N/Treatment before this proc format runs;
** or else hardcode the values in the format;
** or else use a different technique to get the headers;
%let t1_cnt = 111;
%let t2_cnt = 222;
  
proc format;
  value treatf 1="Treatment 1/N=&amp;amp;t1_cnt"
               2="Treatment 2/N=&amp;amp;t2_cnt";
  value locf 1="Location 1"
             2="Location 2";
run;

title;
ods escapechar='~';
Title '1) Using ESCAPECHAR in column header for Col1 and Col2';
title2 'But use SPLIT default character for Treatment labels';
Proc report data = fakedata
     style(header)={vjust=b};
column (" Label ~n more label" Col1 ) ("Label ~n more label" Col2) Treatment,Location,Value;
define Col1   / '' group order=internal;
define Col2 / '' group order=internal;
define treatment / '' across order=internal f=treatf.;
define location/ '' across order=internal f=locf.;
define Value/sum '';
run;


Title '2) Using default SPLIT for line feed in header';
title2 'adding N= as second line for Treatment';
Proc report data = fakedata
     style(header)={vjust=b};
column ('Label/more label' Col1) ('Label/more label' Col2) Treatment,Location,Value;
define Col1   / '' group order=internal;
define Col2 / '' group order=internal;
define treatment / '' across order=internal f=trtnf.;
define location/ '' across order=internal f=locf.;
define Value/sum '';
run;

title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; Notice that all of the column headers in the DEFINE statements are turned off with the empty or null &lt;FONT face="courier new,courier"&gt;''&lt;/FONT&gt; as the label -- that means the spanning headers in the COLUMN statement will be used for Col1 and Col2 and the VALUES for TREATMENT and LOCATION will be visible for the OTHER HEADERS. Example #3 blanks all headers in the DEFINE, but example #4 only blanks some headers:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1738721170825.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104349iA9C870C24BDD0633/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1738721170825.png" alt="Cynthia_sas_0-1738721170825.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here's the code that used the same FAKEDATA file to generate those outputs:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Title '3) show ALL headers including spanning Headers';
Proc report data = fakedata
     style(header)={vjust=b};
column ('Label/more label' Col1) ('Label/more label' Col2) Treatment,Location,Value;
define Col1   / 'Col1' group order=internal;
define Col2 / 'Col2' group order=internal;
define treatment / 'Treatment' across order=internal f=trtnf.;
define location/ 'Location' across order=internal f=locf.;
define Value/sum 'Value';
run;


Title '4) Only blank out some headers';
Proc report data = fakedata
     style(header)={vjust=b};
column ('Label/more label' Col1) ('Label/more label' Col2) Treatment,Location,Value;
define Col1   / 'Col1' group order=internal;
define Col2 / 'Col2' group order=internal;
define treatment / '' across order=internal f=trtnf.;
define location/ '' across order=internal f=locf.;
define Value/sum '';
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 02:17:03 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2025-02-05T02:17:03Z</dc:date>
    <item>
      <title>Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958201#M83889</link>
      <description>&lt;P&gt;I have a report template set up as follows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have grouping columns which require carriage returns but further right in the report, I have formatted nested across columns. It works, but since&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My current proc report code looks like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc report data = xxxx;&lt;/P&gt;
&lt;P&gt;column (" Label ~n more label" A ) ("Label ~n more label" B) Treatment,Location,Value dummy;&lt;/P&gt;
&lt;P&gt;define A&amp;nbsp; &amp;nbsp; / '' group order = internal;&lt;/P&gt;
&lt;P&gt;define B / ' ' group order = internal;&lt;/P&gt;
&lt;P&gt;define treatment / '' across order = internal;&lt;/P&gt;
&lt;P&gt;define location/ '' across order = internal;&lt;/P&gt;
&lt;P&gt;define Value/group '';&lt;/P&gt;
&lt;P&gt;define dummy/ noprint;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Treatment is a formatted value with the population count so it has the form "Treatment 1~n(N = xx) - Treatment 2 is the same&lt;/P&gt;
&lt;P&gt;Location is also a formatted numeric value (Left or Right)&lt;/P&gt;
&lt;P&gt;Value contains the reported values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue is that I have extra space in the across rows because of the carriage returns in A, B and the treatment columns when doing this (see below). Is there any way to get the labels for the treatments pushed down one row? I prefer not to use PROC TRANSPOSE for this operation as treatments could be added later and I need something flexible. The report runs as expected with no errors, warnings or undesired messages returned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_Hopper_2-1738679279596.png" style="width: 766px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104306iBCED88B5D7B2D012/image-dimensions/766x127?v=v2" width="766" height="127" role="button" title="_Hopper_2-1738679279596.png" alt="_Hopper_2-1738679279596.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 14:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958201#M83889</guid>
      <dc:creator>_Hopper</dc:creator>
      <dc:date>2025-02-04T14:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958205#M83890</link>
      <description>&lt;P&gt;It's always better to provide sample data (it could be fake data, as long as it illustrates the problem), as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;examples and instructions&lt;/A&gt;) and not as Excel files and not as copy and paste from Excel or elsewhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an alternative, illustrate the problem you are having with packaged data sets that everyone has such as SASHELP.CARS or SASHELP.CLASS or any other data set in library SASHELP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We consider this to be mandatory in your future posts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my solution using SASHELP.CARS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data = sashelp.cars split='~';
    column (" " make ) type,origin,msrp dummy;
    define make    / 'MAKE' group order = internal;
    define type / '' across order = internal;
    define origin/ '' across order = internal;
    define msrp/mean 'MSRP';
    define dummy/ noprint;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 14:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958205#M83890</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-04T14:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958208#M83891</link>
      <description>&lt;P&gt;Here is what the sample data would look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="842"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="195"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="195"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="133"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="150"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="169"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Text value&lt;/TD&gt;
&lt;TD&gt;Text value&lt;/TD&gt;
&lt;TD&gt;Numeric&lt;/TD&gt;
&lt;TD&gt;Numeric&lt;/TD&gt;
&lt;TD&gt;Numeric converted to text.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="195"&gt;Label has carrriage return in it&lt;/TD&gt;
&lt;TD width="195"&gt;Label has carrriage return in it&lt;/TD&gt;
&lt;TD width="133"&gt;Formatted values Treatment ~n(N = xx)&lt;/TD&gt;
&lt;TD width="150"&gt;Formatted values Treatment ~n(N = xx)&lt;/TD&gt;
&lt;TD width="169"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Column 1&lt;/TD&gt;
&lt;TD&gt;Column 2&lt;/TD&gt;
&lt;TD&gt;Treatment&lt;/TD&gt;
&lt;TD&gt;Location&lt;/TD&gt;
&lt;TD&gt;Value&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;13&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;16&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;17&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;18&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;19&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;22&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;24&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;25&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 04 Feb 2025 15:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958208#M83891</guid>
      <dc:creator>_Hopper</dc:creator>
      <dc:date>2025-02-04T15:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958210#M83892</link>
      <description>&lt;P&gt;Thanks, but I can't use data in that format. I gave specific instructions about how to provide data, and also said not to provide data in Excel files and not to provide data as copy/paste from Excel.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 15:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958210#M83892</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-04T15:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958211#M83893</link>
      <description>The Location values just have a single word format - no carriage return. My error.</description>
      <pubDate>Tue, 04 Feb 2025 15:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958211#M83893</guid>
      <dc:creator>_Hopper</dc:creator>
      <dc:date>2025-02-04T15:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958215#M83894</link>
      <description>&lt;P&gt;Test data&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 15:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958215#M83894</guid>
      <dc:creator>_Hopper</dc:creator>
      <dc:date>2025-02-04T15:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958218#M83895</link>
      <description>&lt;P&gt;It would help if you read my instructions for providing data, you have now provided data in two different ways that I said NOT to do, and you haven't followed the examples and instructions in my post.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 15:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958218#M83895</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-04T15:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958238#M83896</link>
      <description>&lt;P&gt;Using Cars as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;ds escapechar = "~";&lt;/DIV&gt;
&lt;DIV&gt;options orientation = landscape leftmargin = 0.2in rightmargin = 0.2in options missing = '';&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data cars;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; set sashelp.cars;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; msrp2 = round(msrp/1000,.1);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;proc sql;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; create table origin as&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; select&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; strip(origin) as start,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; strip(origin)||"~n( N = "||strip(put(count(origin),8.))||")" as label,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; "origin" as fmtname,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; "C" as type&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; from&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; cars&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; group by&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; origin;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;quit;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;proc format cntlin = origin;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;ods rtf file = "C:\Users\xxx\test.rtf" style = ourstyle;&lt;/DIV&gt;
&lt;DIV&gt;proc report data = cars split='/';&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; column ("Make~n&amp;nbsp; &amp;nbsp; &amp;nbsp;Other Stuff" make ) ("Type~n&amp;nbsp; &amp;nbsp; &amp;nbsp;Other Stuff" type) origin,drivetrain,msrp2 dummy;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; define make&amp;nbsp; &amp;nbsp; / '' group order = internal;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; define type / '' group order = internal ;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; define drivetrain/'' across order =&amp;nbsp; internal;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; define origin/ '' across order = internal format = $origin.;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; define msrp2/mean ' ' format = f8.2;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; define dummy/ noprint;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;ods _all_ close;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generates this output with the formatted value above the others due to the carriage returns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can it be aligned?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_Hopper_0-1738687077703.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104328iAA0A8E25FF31FA29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_Hopper_0-1738687077703.png" alt="_Hopper_0-1738687077703.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 16:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958238#M83896</guid>
      <dc:creator>_Hopper</dc:creator>
      <dc:date>2025-02-04T16:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958241#M83897</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Using some fake data, it is possible to insert your line feeds where you want them without using ODS ESCAPECHAR. PROC REPORT has a default SPLIT character that it allows you to use for headers. The default SPLIT character is a slash / and the advantage of using the default is that it works in all destinations and works without using ODS ESCAPECHAR. And the older style ESCAPECHAR that you used in your code was changed in SAS version 9.2 so although the older syntax still works, I'd either recommend moving to the newer ESCAPECHAR syntax for inserting a line break in the header or just switch to using the default SPLIT character. Here's the code I used to make fake data and generate 2 examples:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1738690345093.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104329i396FC2BA17F85CA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1738690345093.png" alt="Cynthia_sas_0-1738690345093.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I used macro variables for the N= values and just gave them values of 111 and 222 in my %LET statements. In production, of course, you would need to find out the N before creating the format or else write a little routine to make the macro variables to hold each count. I changed your code just a bit. I didn't understand why you needed the dummy variable in the COLUMN statement, so I got rid of it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Hope this helps explain a bit more about PROC REPORT and how to insert line breaks into HEADER rows.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 17:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958241#M83897</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2025-02-04T17:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958243#M83898</link>
      <description>&lt;P&gt;But this does not solve the underlying issue which is getting the column headers where across is used on the lowest level possible. Is this type of result not possible in PROC REPORT when using the across syntax with returns in the headers?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 17:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958243#M83898</guid>
      <dc:creator>_Hopper</dc:creator>
      <dc:date>2025-02-04T17:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958246#M83899</link>
      <description>&lt;P&gt;It seems to have eliminated the blank header row in the across columns.&lt;/P&gt;
&lt;P&gt;How was that accomplished?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: It is impossible to play with your examples when you only post them as photographs.&amp;nbsp; If you think the code it too intrusive in your posting use the Insert a Spoiler Tag icon to hide the code until the user wants to see it.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 17:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958246#M83899</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-04T17:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958304#M83900</link>
      <description>&lt;P&gt;Hi Tom:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the full code. Sorry, my bad. I was planning to color code and annotate in the screen shot but then got called away and so I just posted it without much extra commenting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fakedata;
  infile datalines dlm=',';
  input Col1 $ Col2 $ Treatment Location Value;
datalines;
A, A, 1, 1, 1
A, A, 1, 2, 2
A, A, 2, 1, 3
A, A, 2, 2, 4
A, B, 1, 1, 5
A, B, 1, 2, 6
A, B, 2, 1, 7
A, B, 2, 2, 8
;
run;

** need to assign values to the macro variables for N/Treatment before this proc format runs;
** or else hardcode the values in the format;
** or else use a different technique to get the headers;
%let t1_cnt = 111;
%let t2_cnt = 222;
  
proc format;
  value treatf 1="Treatment 1/N=&amp;amp;t1_cnt"
               2="Treatment 2/N=&amp;amp;t2_cnt";
  value locf 1="Location 1"
             2="Location 2";
run;

title;
ods escapechar='~';
Title '1) Using ESCAPECHAR in column header for Col1 and Col2';
title2 'But use SPLIT default character for Treatment labels';
Proc report data = fakedata
     style(header)={vjust=b};
column (" Label ~n more label" Col1 ) ("Label ~n more label" Col2) Treatment,Location,Value;
define Col1   / '' group order=internal;
define Col2 / '' group order=internal;
define treatment / '' across order=internal f=treatf.;
define location/ '' across order=internal f=locf.;
define Value/sum '';
run;


Title '2) Using default SPLIT for line feed in header';
title2 'adding N= as second line for Treatment';
Proc report data = fakedata
     style(header)={vjust=b};
column ('Label/more label' Col1) ('Label/more label' Col2) Treatment,Location,Value;
define Col1   / '' group order=internal;
define Col2 / '' group order=internal;
define treatment / '' across order=internal f=trtnf.;
define location/ '' across order=internal f=locf.;
define Value/sum '';
run;

title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; Notice that all of the column headers in the DEFINE statements are turned off with the empty or null &lt;FONT face="courier new,courier"&gt;''&lt;/FONT&gt; as the label -- that means the spanning headers in the COLUMN statement will be used for Col1 and Col2 and the VALUES for TREATMENT and LOCATION will be visible for the OTHER HEADERS. Example #3 blanks all headers in the DEFINE, but example #4 only blanks some headers:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1738721170825.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104349iA9C870C24BDD0633/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1738721170825.png" alt="Cynthia_sas_0-1738721170825.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here's the code that used the same FAKEDATA file to generate those outputs:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Title '3) show ALL headers including spanning Headers';
Proc report data = fakedata
     style(header)={vjust=b};
column ('Label/more label' Col1) ('Label/more label' Col2) Treatment,Location,Value;
define Col1   / 'Col1' group order=internal;
define Col2 / 'Col2' group order=internal;
define treatment / 'Treatment' across order=internal f=trtnf.;
define location/ 'Location' across order=internal f=locf.;
define Value/sum 'Value';
run;


Title '4) Only blank out some headers';
Proc report data = fakedata
     style(header)={vjust=b};
column ('Label/more label' Col1) ('Label/more label' Col2) Treatment,Location,Value;
define Col1   / 'Col1' group order=internal;
define Col2 / 'Col2' group order=internal;
define treatment / '' across order=internal f=trtnf.;
define location/ '' across order=internal f=locf.;
define Value/sum '';
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 02:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958304#M83900</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2025-02-05T02:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958305#M83901</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I guess I don't understand what you mean by "ACROSS used on the lowest level possible". Can you tell me what you consider the lowest level possible to be? To me you have VALUE nested as the data cell for each unique combination of LOCATION within TREATMENT. So to me, I would say that LOCATION is the lowest level of ACROSS variable. Do you mean that you want N=?? to be on a new line for every unique combination of LOCATION within each TREATMENT?&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 02:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958305#M83901</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2025-02-05T02:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958306#M83902</link>
      <description>Try to change the position of VALUE:&lt;BR /&gt;Treatment,Location,Value&lt;BR /&gt;-----&amp;gt;&lt;BR /&gt;Value,Treatment,Location</description>
      <pubDate>Wed, 05 Feb 2025 02:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958306#M83902</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-05T02:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using across in PROC REPORT with nesting and labels</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958308#M83903</link>
      <description>&lt;P&gt;So the change was to remove the LABEL of the GROUP variables in the DEFINE statements and instead add the header into the COLUMN statement?&lt;/P&gt;
&lt;P&gt;So this code has the empty cells:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.class;
 column Age sex,weight;
 define age / group ;
 define sex / across;
 define weight / mean ' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But this one does not becuase the label is removed from AGE and instead a string constant is added to the COLUMN statement to replace it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.class;
 column ('Age' age) sex,weight;
 define age / group ' ';
 define sex / across;
 define weight / mean ' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Feb 2025 02:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-across-in-PROC-REPORT-with-nesting-and-labels/m-p/958308#M83903</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-05T02:46:47Z</dc:date>
    </item>
  </channel>
</rss>

