BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
OPHD1
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

2 REPLIES 2
ballardw
Super User

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;

OPHD1
Fluorite | Level 6

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 5396 views
  • 0 likes
  • 2 in conversation