<?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: how to display variables values before column names in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-display-variables-values-before-column-names/m-p/3788#M1599</link>
    <description>A simple way to include data-driven values into reports is to combine BY statements and #BYVALn references (that is, the current value of the n-th variable nammed in a BY statement) in Titles.&lt;BR /&gt;
At least, it works out fine in HTML files ; some tricky things (bugs ?) may appear in Word or PDF files (I've experienced some trouble several times, but I am not currently able to re-generate them on demand).&lt;BR /&gt;
&lt;BR /&gt;
Here is some example on SASHELP dataset.&lt;BR /&gt;
&lt;BR /&gt;
ODS HTML FILE='c:\temp\header_method3.html' STYLE=SASWEB;&lt;BR /&gt;
PROC SORT DATA = sashelp.class OUT = work.class ;&lt;BR /&gt;
	BY age sex name ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC FORMAT ;&lt;BR /&gt;
	VALUE $sex "F" = "The girls are..." "M" = "The boys are..." ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
OPTION NOBYLINE ;&lt;BR /&gt;
TITLE1 "List of children being #BYVAL1" ;&lt;BR /&gt;
TITLE2 "#BYVAL2" ;&lt;BR /&gt;
PROC PRINT DATA = work.class NOOBS LABEL ;&lt;BR /&gt;
	BY age sex ;&lt;BR /&gt;
	VAR name weight height ;&lt;BR /&gt;
	FORMAT sex $sex. ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
TITLE ;&lt;BR /&gt;
ODS HTML CLOSE ;&lt;BR /&gt;
&lt;BR /&gt;
Hope it helps.&lt;BR /&gt;
Olivier</description>
    <pubDate>Tue, 17 Jul 2007 12:53:53 GMT</pubDate>
    <dc:creator>Olivier</dc:creator>
    <dc:date>2007-07-17T12:53:53Z</dc:date>
    <item>
      <title>how to display variables values before column names</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-display-variables-values-before-column-names/m-p/3786#M1597</link>
      <description>I have the following query in getting the below output.&lt;BR /&gt;
    &lt;BR /&gt;
&lt;BR /&gt;
                                   Report Name&lt;BR /&gt;
&lt;BR /&gt;
  Lab Test: XXX&lt;BR /&gt;
  Unit: XXX&lt;BR /&gt;
 &lt;BR /&gt;
 Subjid        Age      Sex  Low Hight&lt;BR /&gt;
 1                 65        M     11     112&lt;BR /&gt;
                                         13     234&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I didn’t get how to print the ‘Lab Test: XXX’ . ‘XXX’ should be replaced by values of ‘lbtest’ from the dataset.&lt;BR /&gt;
And we have more than one labtest with repeated values. I want to print the data of subjects for each lab test.&lt;BR /&gt;
I got entire report except printing of ‘Lab Test: XXX’. &lt;BR /&gt;
So please help me</description>
      <pubDate>Thu, 12 Jul 2007 09:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-display-variables-values-before-column-names/m-p/3786#M1597</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-07-12T09:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to display variables values before column names</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-display-variables-values-before-column-names/m-p/3787#M1598</link>
      <description>Hi:&lt;BR /&gt;
  You did not say what your report procedure of choice was or what your destination was. There are at least 3 different methods to do what you want. Without getting into the possibility of a custom table template or SAS Macro processing, the 3 methods below use PROC REPORT. However, the first method uses PROC REPORT and compute blocks and the second method uses PROC REPORT with a BY statement and TITLES to place that kind of identifying information above the table (in the Title); the third method uses PROC REPORT's COMPUTE BEFORE _PAGE_ capability to place the headers inside the boundary of the table area.&lt;BR /&gt;
  &lt;BR /&gt;
The second method will put every unique combination of Region and Subsidiary on a separate page -- which may or may not be what you want. In the first method, paging will depend on the destination -- which means that there are no "between group" page breaks. The third method will put every unique combination of Region and Subsidiary on a separate page, too. But in my example, the STARTPAGE=NO option will suppress the page breaks for RTF and PDF destinations.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
*** the code;&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
title;&lt;BR /&gt;
   &lt;BR /&gt;
proc sort data=sashelp.shoes out=shoes;&lt;BR /&gt;
by region subsidiary;&lt;BR /&gt;
where region in ('Asia', 'Canada', 'Pacific');&lt;BR /&gt;
run;&lt;BR /&gt;
   &lt;BR /&gt;
** this method uses PROC REPORT compute blocks to place the headers;&lt;BR /&gt;
** on the page based on their existence in the column statement;&lt;BR /&gt;
** since they are NOPRINT variables, they can be used in the COMPUTE block;&lt;BR /&gt;
ods rtf file='header_method1.rtf';&lt;BR /&gt;
ods pdf file='header_method1.pdf';&lt;BR /&gt;
ods html file='header_method1.html' style=sasweb;&lt;BR /&gt;
  proc report data=shoes nowd;&lt;BR /&gt;
     title '1) Custom Header Method1 -- with compute block';&lt;BR /&gt;
     column region subsidiary product sales returns inventory;&lt;BR /&gt;
     define region /group noprint;&lt;BR /&gt;
     define subsidiary /group noprint;&lt;BR /&gt;
     define product /order ;&lt;BR /&gt;
     define sales / sum ;&lt;BR /&gt;
     define returns/ sum;&lt;BR /&gt;
     define inventory /sum;&lt;BR /&gt;
     break after subsidiary/summarize;&lt;BR /&gt;
     compute before region;&lt;BR /&gt;
         holdreg = Region;&lt;BR /&gt;
     endcomp;&lt;BR /&gt;
     compute before subsidiary /&lt;BR /&gt;
         style={just=l};&lt;BR /&gt;
        holdsub = Subsidiary;&lt;BR /&gt;
        line 'Region: ' holdreg $25.;&lt;BR /&gt;
        line 'Subsidiary: ' holdsub $25.;&lt;BR /&gt;
     endcomp; &lt;BR /&gt;
    compute after subsidiary;&lt;BR /&gt;
        line ' ';&lt;BR /&gt;
    endcomp;&lt;BR /&gt;
    run;&lt;BR /&gt;
ods _all_ close;&lt;BR /&gt;
    &lt;BR /&gt;
** this method generates a page for every "group" and uses the TITLE statement;&lt;BR /&gt;
** to place the "header" information;&lt;BR /&gt;
** If you use startpage=no for RTF and PDF with this method, you will only keep;&lt;BR /&gt;
** the title for the first table on the page -- which may not be what you want;&lt;BR /&gt;
ods rtf file='header_method2.rtf';&lt;BR /&gt;
ods pdf file='header_method2.pdf';&lt;BR /&gt;
ods html file='header_method2.html' style=sasweb;&lt;BR /&gt;
options nobyline nocenter;&lt;BR /&gt;
title j=l 'Region: #byval(region)';&lt;BR /&gt;
title2 j=l 'Subsidiary: #byval(subsidiary)';&lt;BR /&gt;
  proc report data=shoes nowd;&lt;BR /&gt;
     by region subsidiary;&lt;BR /&gt;
     column region subsidiary product sales returns inventory;&lt;BR /&gt;
     define region /group noprint;&lt;BR /&gt;
     define subsidiary /group noprint;&lt;BR /&gt;
     define product /order ;&lt;BR /&gt;
     define sales / sum ;&lt;BR /&gt;
     define returns/ sum;&lt;BR /&gt;
     define inventory /sum;&lt;BR /&gt;
     break after subsidiary / summarize;&lt;BR /&gt;
     run;&lt;BR /&gt;
ods _all_ close;&lt;BR /&gt;
   &lt;BR /&gt;
options byline center;&lt;BR /&gt;
title;&lt;BR /&gt;
  &lt;BR /&gt;
** this method uses a variation of Method 1 but has some of the benefits of ;&lt;BR /&gt;
** Method2 -- in that you can get every table on a page or not -- your choice.;&lt;BR /&gt;
** It uses the page option on the BREAK statement and then a;&lt;BR /&gt;
** COMPUTE before _PAGE_ to place the text above the columns;&lt;BR /&gt;
** the startpage=no option for RTF and PDF places multiple tables on a page;&lt;BR /&gt;
** if you want every table on a separate page, then delete the "startpage=no" option.;&lt;BR /&gt;
ods rtf file='header_method3.rtf' startpage=no;&lt;BR /&gt;
ods pdf file='header_method3.pdf' startpage=no;&lt;BR /&gt;
ods html file='header_method3.html' style=sasweb;&lt;BR /&gt;
  proc report data=shoes nowd;&lt;BR /&gt;
     title '3) Custom Header Method3 -- with compute block before _page_';&lt;BR /&gt;
     column region subsidiary product sales returns inventory;&lt;BR /&gt;
     define region /group noprint;&lt;BR /&gt;
     define subsidiary /group noprint;&lt;BR /&gt;
     define product /order ;&lt;BR /&gt;
     define sales / sum ;&lt;BR /&gt;
     define returns/ sum;&lt;BR /&gt;
     define inventory /sum;&lt;BR /&gt;
     break after subsidiary/summarize page;&lt;BR /&gt;
     compute before region;&lt;BR /&gt;
         holdreg = Region;&lt;BR /&gt;
     endcomp;&lt;BR /&gt;
     compute before _page_ /&lt;BR /&gt;
         style={just=l font_weight=bold foreground=black};&lt;BR /&gt;
        holdsub = Subsidiary;&lt;BR /&gt;
        line 'Region: ' holdreg $25.;&lt;BR /&gt;
        line 'Subsidiary: ' holdsub $25.;&lt;BR /&gt;
     endcomp; &lt;BR /&gt;
     run;&lt;BR /&gt;
ods _all_ close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 13 Jul 2007 16:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-display-variables-values-before-column-names/m-p/3787#M1598</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-07-13T16:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to display variables values before column names</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-display-variables-values-before-column-names/m-p/3788#M1599</link>
      <description>A simple way to include data-driven values into reports is to combine BY statements and #BYVALn references (that is, the current value of the n-th variable nammed in a BY statement) in Titles.&lt;BR /&gt;
At least, it works out fine in HTML files ; some tricky things (bugs ?) may appear in Word or PDF files (I've experienced some trouble several times, but I am not currently able to re-generate them on demand).&lt;BR /&gt;
&lt;BR /&gt;
Here is some example on SASHELP dataset.&lt;BR /&gt;
&lt;BR /&gt;
ODS HTML FILE='c:\temp\header_method3.html' STYLE=SASWEB;&lt;BR /&gt;
PROC SORT DATA = sashelp.class OUT = work.class ;&lt;BR /&gt;
	BY age sex name ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC FORMAT ;&lt;BR /&gt;
	VALUE $sex "F" = "The girls are..." "M" = "The boys are..." ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
OPTION NOBYLINE ;&lt;BR /&gt;
TITLE1 "List of children being #BYVAL1" ;&lt;BR /&gt;
TITLE2 "#BYVAL2" ;&lt;BR /&gt;
PROC PRINT DATA = work.class NOOBS LABEL ;&lt;BR /&gt;
	BY age sex ;&lt;BR /&gt;
	VAR name weight height ;&lt;BR /&gt;
	FORMAT sex $sex. ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
TITLE ;&lt;BR /&gt;
ODS HTML CLOSE ;&lt;BR /&gt;
&lt;BR /&gt;
Hope it helps.&lt;BR /&gt;
Olivier</description>
      <pubDate>Tue, 17 Jul 2007 12:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-display-variables-values-before-column-names/m-p/3788#M1599</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2007-07-17T12:53:53Z</dc:date>
    </item>
  </channel>
</rss>

