<?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: Modifying how to print a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737437#M229898</link>
    <description>Thank you Reeza, for your suggestions and for noticing the missing part in my code. I connected the code in my original post. &lt;BR /&gt;&lt;BR /&gt;I want to keep Age, but somewhere I would like to have the label as well. Age is the name of the variable and I want to keep them for easy access to variable names when reading the report.&lt;BR /&gt;&lt;BR /&gt;After using the ODS OUTPUT, Label is a column of my data and not the label of a variable anymore. &lt;BR /&gt;Thanks</description>
    <pubDate>Tue, 27 Apr 2021 21:10:09 GMT</pubDate>
    <dc:creator>Emma_at_SAS</dc:creator>
    <dc:date>2021-04-27T21:10:09Z</dc:date>
    <item>
      <title>Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737419#M229881</link>
      <description>&lt;P&gt;I am putting some summary tables in datasets to print for a report. Below, I copied the code to save the label to come with the datasets:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output OneWay=Output; &lt;BR /&gt;proc surveyfreq data = &amp;amp;dataset VARHEADER = NAMELABEL nosummary;
tables &amp;amp;varname/cl nofreq nostd;
weight &amp;amp;weight_var;
run;

data output;
set output;
label = vlabelx(scan(table,2,' '));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to keep the labels; however, I do not want the labels to be on every row of my tables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any way I can print the label only once? Please see an example of my output report below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="526"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TD width="123.2px"&gt;
&lt;P&gt;AGE&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.8px"&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;label&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;Frequency&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;Percent&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;L_95_p_CI&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;U_95_p_CI&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="123.2px"&gt;
&lt;P&gt;10-20 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.8px"&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;Age categories&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;379&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;19.5&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;17.1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;21.9&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="123.2px"&gt;
&lt;P&gt;21-30 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.8px"&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;Age categories&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;460&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;23.7&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;21.3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;26.1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="123.2px"&gt;
&lt;P&gt;31-40 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.8px"&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;Age&amp;nbsp; categories&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;380&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;19.6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;17.6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;21.5&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="123.2px"&gt;
&lt;P&gt;41-50 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.8px"&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;Age&amp;nbsp; categories&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;369&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;19.0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;17.0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;20.9&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="123.2px"&gt;
&lt;P&gt;51-60 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.8px"&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;Age categories&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;354&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;18.3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;16.6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;19.9&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 21:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737419#M229881</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T21:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737421#M229882</link>
      <description>&lt;P&gt;PROC PRINT and PROC REPORT allow you to choose which data set variables get printed;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=yourdatasetname;
var age frequency percent l_95_p_ci u_95_p_ci;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 20:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737421#M229882</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-27T20:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737425#M229886</link>
      <description>You're aware that those two code segments are not connected at all?&lt;BR /&gt;&lt;BR /&gt;Where do you want to see the label? I'd assume that instead of "AGE" you want to see "Age Categories". &lt;BR /&gt;&lt;BR /&gt;Add the LABEL option to the PROC PRINT statement to see the labels and drop the Label column entirely. &lt;BR /&gt;</description>
      <pubDate>Tue, 27 Apr 2021 20:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737425#M229886</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-27T20:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737432#M229893</link>
      <description>&lt;P&gt;Proc Report would show the default assigned variable label as a column heading.&lt;/P&gt;
&lt;P&gt;This adds a new label to the variable name in a data set you should have available to demonstrate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.class;
   set sashelp.class;
   label name='Student name';
run;

proc report data=work.class;
   columns name sex age;
run;&lt;/PRE&gt;
&lt;P&gt;Or you can provide a label to override the existing one in a define statement:&lt;/P&gt;
&lt;PRE&gt;proc report data=work.class;
   columns name sex  age ;
   define age/ 'Age at enrollment';
run;&lt;/PRE&gt;
&lt;P&gt;Or use a variable as a Group variable&lt;/P&gt;
&lt;PRE&gt;proc report data=work.class;
   columns sex name  age ;
   define sex / group;
   define age/ 'Age at enrollment';
run;&lt;/PRE&gt;
&lt;P&gt;Though Proc Report would want the "group" variable text to appear to the left of the categories. Note that the Columns statement provides the order left to right of the columns that appear in the output.&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, 27 Apr 2021 21:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737432#M229893</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-27T21:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737435#M229896</link>
      <description>Thank you, PaigeMiller. But that removes the label completely. I want it but only once not on each row. Thanks</description>
      <pubDate>Tue, 27 Apr 2021 21:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737435#M229896</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T21:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737437#M229898</link>
      <description>Thank you Reeza, for your suggestions and for noticing the missing part in my code. I connected the code in my original post. &lt;BR /&gt;&lt;BR /&gt;I want to keep Age, but somewhere I would like to have the label as well. Age is the name of the variable and I want to keep them for easy access to variable names when reading the report.&lt;BR /&gt;&lt;BR /&gt;After using the ODS OUTPUT, Label is a column of my data and not the label of a variable anymore. &lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 27 Apr 2021 21:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737437#M229898</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T21:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737440#M229901</link>
      <description>Thank you, ballardw, for your suggestion. I want to keep the variable name age as is. I want to add the label in some form once. the label is not really a label anymore. It is a column of my dataset that is repeating itself for all rows, which makes it too repetitive in a long report. Thanks</description>
      <pubDate>Tue, 27 Apr 2021 21:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737440#M229901</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T21:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737447#M229908</link>
      <description>&lt;P&gt;SAS makes it hard for us to do things that are not logical.&lt;/P&gt;
&lt;P&gt;You've shown us so far only your not desired report. How should your desired report look like?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 21:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737447#M229908</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-27T21:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737450#M229911</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you, ballardw, for your suggestion. I want to keep the variable name age as is. I want to add the label in some form once. the label is not really a label anymore. It is a column of my dataset that is repeating itself for all rows, which makes it too repetitive in a long report. Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is exactly what a GROUP variable does in proc report.&lt;/P&gt;
&lt;P&gt;Provide and actual example of your data set in the form of data step code and I'll show you how. Though the last example I provided should work: change the data set to yours, your variables on the columns state with the Label variable first, Define the Label variable as a Group variable.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 21:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737450#M229911</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-27T21:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737458#M229918</link>
      <description>&lt;P&gt;Good point, Patrik. My ideal table looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;Age categories&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE width="456px"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TD width="120.8px"&gt;
&lt;P&gt;AGE&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;Frequency&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;Percent&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;L_95_p_CI&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;U_95_p_CI&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="120.8px"&gt;
&lt;P&gt;10-20 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;379&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;19.5&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;17.1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;21.9&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="120.8px"&gt;
&lt;P&gt;21-30 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;460&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;23.7&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;21.3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;26.1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="120.8px"&gt;
&lt;P&gt;31-40 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;380&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;19.6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;17.6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;21.5&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="120.8px"&gt;
&lt;P&gt;41-50 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;369&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;19.0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;17.0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;20.9&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="120.8px"&gt;
&lt;P&gt;51-60 years&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="86.4px"&gt;
&lt;P&gt;354&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="66.4px"&gt;
&lt;P&gt;18.3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="89.6px"&gt;
&lt;P&gt;16.6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="92px"&gt;
&lt;P&gt;19.9&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 21:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737458#M229918</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T21:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737460#M229919</link>
      <description>&lt;P&gt;Thanks, ballardw. I try your previous code and will send an update shortly. Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 21:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737460#M229919</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T21:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737462#M229920</link>
      <description>&lt;P&gt;Thanks, ballardw. I tried the GROUP code but I think I am doing something wrong because it grouped all rows. My code and the new table are copied below. I am going to send my full code in a separate post. Thanks&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=output3;
   columns label &amp;amp;varname Frequency Percent L_95_p_CI U_95_p_CI  ;
   define label / group;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;HR size="3" /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Report: Detailed and/or summarized report" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col"&gt;label&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;Age&amp;nbsp; categories&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;Weighted Frequency&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;Percent&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;95% Lower Confidence Limit, Percent&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;95% Upper Confidence Limit, Percent&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Age&amp;nbsp; categories&lt;/TD&gt;
&lt;TD class="r data"&gt;15&lt;/TD&gt;
&lt;TD class="r data"&gt;1941&lt;/TD&gt;
&lt;TD class="r data"&gt;100.0&lt;/TD&gt;
&lt;TD class="r data"&gt;89.7&lt;/TD&gt;
&lt;TD class="r data"&gt;110.3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 27 Apr 2021 22:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737462#M229920</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T22:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737464#M229921</link>
      <description>&lt;P&gt;Below is the full code that I am using. I hope it helps. Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro macro_surveyfreq(varname);
ods exclude all;
ods output OneWay=Output; 
proc surveyfreq data = &amp;amp;dataset VARHEADER = NAMELABEL nosummary;
    tables &amp;amp;varname/cl nofreq nostd; 
	weight &amp;amp;weight_var;
run;
data output;
    set output;
    label = vlabelx(scan(table,2,' '));
run;
proc print data=output; run;

data output1; 
set output (drop=Table F_&amp;amp;varname _SkipLine) end=last; 
if not last then output;
run;

data output2 (rename= (WgtFreq=Frequency LowerCL=L_95_p_CI UpperCL=U_95_p_CI));
set output1;
run;
proc print data=output2 noobs; run;

data output3;
   retain &amp;amp;varname 
	label
	Frequency
	Percent 
	L_95_p_CI 
	U_95_p_CI ;
   set output2;
run;

ods exclude none;

proc print data=output3 noobs; run; *this is the table that goes into report;

%mend;&lt;BR /&gt;&lt;BR /&gt;ods word file="D:\path\PROC_SURVEYFREQ.docx" STARTPAGE=NO;&lt;BR /&gt;%macro_surveyfreq(age);&lt;BR /&gt;%macro_surveyfreq(gender_3_levels);&lt;BR /&gt;%macro_surveyfreq(education_level);&lt;BR /&gt;%macro_surveyfreq(income_4_cat);&lt;BR /&gt;*my list is long here;&lt;BR /&gt;ods word close;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 22:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737464#M229921</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T22:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737469#M229924</link>
      <description>&lt;P&gt;Seems simple enough.&lt;/P&gt;
&lt;P&gt;Since you didn't provide any example data let's convert your posted table into a dataset.&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
 infile cards truncover ;
input 
(AGE
label
Frequency
Percent
L_95_p_CI
U_95_p_CI ) ($50./);
cards;
10-20 years
Age categories
379
19.5
17.1
21.9
21-30 years
Age categories
460
23.7
21.3
26.1
31-40 years
Age categories
380
19.6
17.6
21.5
41-50 years
Age categories
369
19.0
17.0
20.9
51-60 years
Age categories
354
18.3
16.6
19.9
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;So just use BY statement.&amp;nbsp; For example with PROC REPORT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have ;
 by label ;
 column  age 
Frequency
Percent
L_95_p_CI
U_95_p_CI 
 ;
 define _all_  / display;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 477px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58753i8E886F61726C69F5/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.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;</description>
      <pubDate>Tue, 27 Apr 2021 23:04:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737469#M229924</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-27T23:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737474#M229926</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro macro_surveyfreq(varname);
ods exclude all;
ods output OneWay=Output; 
proc surveyfreq data = &amp;amp;dataset VARHEADER = NAMELABEL nosummary;
    tables &amp;amp;varname/cl nofreq nostd; 
	weight &amp;amp;weight_var;
run;
data output;
    set output;
    label = vlabelx(scan(table,2,' '));
run;
proc print data=output; run;

data output1; 
set output (drop=Table F_&amp;amp;varname _SkipLine) end=last; 
if not last then output;
run;

data output2 (rename= (WgtFreq=Frequency LowerCL=L_95_p_CI UpperCL=U_95_p_CI));
set output1;
run;
proc print data=output2 noobs; run;

proc sql noprint;
select distinct label into :title_name from output2;
quit;

data output3;
   retain &amp;amp;varname 
	Frequency
	Percent 
	L_95_p_CI 
	U_95_p_CI ;
   set output2;
drop label;
run;

ods exclude none;

title j=l "&amp;amp;title_name.";
proc print data=output3 noobs; run; *this is the table that goes into report;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 23:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737474#M229926</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-27T23:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737597#M229977</link>
      <description>&lt;P&gt;Thank you, everyone!&lt;/P&gt;
&lt;P&gt;For more information please review the last post from Tom and Reeza.&lt;/P&gt;
&lt;P&gt;In summary, an efficient way to remove repeated labels and add the label at the top of the table is to save the label, for example in title_name&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;proc sql noprint;
select distinct label into :title_name from output2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;and then call that title_name in a title when printing the output&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;title j=l "&amp;amp;title_name.";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 14:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737597#M229977</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-28T14:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737598#M229978</link>
      <description>Thank you, Tom. This is great!</description>
      <pubDate>Wed, 28 Apr 2021 14:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737598#M229978</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-28T14:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737599#M229979</link>
      <description>Thank you, Reeza. I used this in my code and it works perfectly.</description>
      <pubDate>Wed, 28 Apr 2021 14:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737599#M229979</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-28T14:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737958#M230111</link>
      <description>&lt;P&gt;Reeza, thank you again for your code. Now, I want to use it on another occasion but I could not modify it very well.&lt;/P&gt;
&lt;P&gt;I am using the following code to save the labels and print them above the tables in my report. In my SAS output, it works perfect and copies each label above each table (sample output below)&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l systemtitle"&gt;AGE: How old are you?&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.OUTPUT5" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col" width="58.4px" height="19px"&gt;VarName&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="51.2px" height="19px"&gt;Mean&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="51.2px" height="19px"&gt;SD&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="68.8px" height="19px"&gt;L_95_p_CI&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="71.2px" height="19px"&gt;U_95_p_CI&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="46.4px" height="19px"&gt;N&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="58.4px" height="29px" class="l data"&gt;AGE&lt;/TD&gt;
&lt;TD width="51.2px" height="29px" class="r data"&gt;39.88&lt;/TD&gt;
&lt;TD width="51.2px" height="29px" class="r data"&gt;14.25&lt;/TD&gt;
&lt;TD width="68.8px" height="29px" class="r data"&gt;39.14&lt;/TD&gt;
&lt;TD width="71.2px" height="29px" class="r data"&gt;40.62&lt;/TD&gt;
&lt;TD width="46.4px" height="29px" class="r data"&gt;1250&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;However, in my ODS WORD file, only the label for the first variable in the list appears. May you please help me to resolve this issue, please? Thanks&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro do_sm(varname);
ods exclude all;
data output3;
   retain VarName 
	VarLabel
	Mean
	&amp;amp;varname
	LowerCLMean
	UpperCLMean
	N;
   set output2;
run;

data output4 (rename=(VarName=VarName
						   VarLabel=Label
						   &amp;amp;varname=SD
						   LowerCLMean=L_95_p_CI 
						   UpperCLMean=U_95_p_CI));
set output3;
run;

&lt;FONT color="#0000FF"&gt;proc sql noprint;
select distinct Label into :title_name from output4;
quit;&lt;/FONT&gt;

data output5 (drop=Label); set output4; run;

ods exclude none;

&lt;FONT color="#0000FF"&gt;title j=l "&amp;amp;title_name.";&lt;/FONT&gt;
proc print data=output5 noobs; run;

             
%mend do_sm;

&lt;FONT color="#0000FF"&gt;ods word file="D:path\REPORT_&amp;amp;DATE..docx" STARTPAGE=NO;
OPTIONS NONUMBER NODATE FORMDLIM='~';&lt;/FONT&gt;
%do_sm(age);
%do_sm(money);&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;ods&amp;nbsp;word&amp;nbsp;close;&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 16:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737958#M230111</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-29T16:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying how to print a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737963#M230112</link>
      <description>Reset title name between runs so set it to missing before the PROC SQL. I'm guessing that money doesn't actually have a label so it stays with the old value. &lt;BR /&gt;&lt;BR /&gt;*set to missing;&lt;BR /&gt;%let title_name = ;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select distinct Label into :title_name from output4;&lt;BR /&gt;quit;</description>
      <pubDate>Thu, 29 Apr 2021 16:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modifying-how-to-print-a-dataset/m-p/737963#M230112</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-29T16:35:56Z</dc:date>
    </item>
  </channel>
</rss>

