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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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