The SAS Output Delivery System and reporting techniques

How to Add Header in Data Table

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

How to Add Header in Data Table

I would like to add a header above my column names in a data table.

For example, using this sample data:

data how_2_header;

     length measure $ 25;

     input measure $ group1_rt group1_lcl group1_ucl group2_rt group2_lcl group2_ucl group3_rt group3_lcl group3_ucl;

     label group1_rt = Rate;

     label group1_lcl = LCL;

     label group1_ucl = UCL;

     label group2_rt = Rate;

     label group2_lcl = LCL;

     label group2_ucl = UCL;

     label group3_rt = Rate;

     label group3_lcl = LCL;

     label group3_ucl = UCL;

     datalines;

          Measure1 100 50 150 100 75 125 75 70 80

          Measure2 40 20 60 40 30 50 30 25 35

          ;

run;

How to I create a header for each Group merged and centered above all Group x entries

                          Group 1                     Group 2                        Group 3

Measure     Rate     LCL     UCL     Rate     LCL     UCL     Rate     LCL     UCL

Measure1   100       50       150      100       75        25       75        70       80

Measure2    40        20        60        40        30        50       30        25       35


Accepted Solutions
Solution
‎05-09-2013 12:54 PM
Grand Advisor
Posts: 9,740

Re: How to Add Header in Data Table

Not actually going to work in an actual data table.

If you structure your data so that you have a group, rate, lcl and ucl then you can accomplish that for reporting purposes using either Proc Report or Tabulate.

data restructure (keep= measure group rate lcl ucl);

     set how_2_header;

     Group=1; rate=group1_rt; lcl=group1_lcl;ucl=group1_ucl;output;

     Group=2; rate=group2_rt; lcl=group2_lcl;ucl=group2_ucl;output;

     Group=3; rate=group3_rt; lcl=group3_lcl;ucl=group3_ucl;output;

run;

proc tabulate data=restructure;

class measure;

class group;

var rate lcl ucl;

table measure=' ',

        group = ' ' *(rate lcl ucl)*max='' *f=best5.;

run;

View solution in original post


All Replies
Solution
‎05-09-2013 12:54 PM
Grand Advisor
Posts: 9,740

Re: How to Add Header in Data Table

Not actually going to work in an actual data table.

If you structure your data so that you have a group, rate, lcl and ucl then you can accomplish that for reporting purposes using either Proc Report or Tabulate.

data restructure (keep= measure group rate lcl ucl);

     set how_2_header;

     Group=1; rate=group1_rt; lcl=group1_lcl;ucl=group1_ucl;output;

     Group=2; rate=group2_rt; lcl=group2_lcl;ucl=group2_ucl;output;

     Group=3; rate=group3_rt; lcl=group3_lcl;ucl=group3_ucl;output;

run;

proc tabulate data=restructure;

class measure;

class group;

var rate lcl ucl;

table measure=' ',

        group = ' ' *(rate lcl ucl)*max='' *f=best5.;

run;

Contributor
Posts: 28

Re: How to Add Header in Data Table

Thank you very much. Just tried it out, this was very helpful.

Post a Question
Discussion Stats
  • 2 replies
  • 925 views
  • 0 likes
  • 2 in conversation