BookmarkSubscribeRSS Feed
Lost_Gary
Obsidian | Level 7

Is there a way to combine headers with the same label within the proc print function?  For Instance, if I labeled gave both the firstname and lastname fields the same label as "name", could I run some variation such as:

proc print data=mydata label;

var firstname lastname /style(header)=[background =lightblue ];

run;

 

and get an output of:

Name
Bob Jones
Daffy  Duck

 

 

1 REPLY 1
ballardw
Super User

Not in proc Print.

 

You can do this with Proc Report:

data have;
   input name1 $ name2 $;
datalines;
Bob Jim
Fred Barney
;

proc report data=have;
   column ("Name label"  name1 name2);
   define name1 /"" ;
   define name2 /"";
run;

The ("Name label" name1 name2) sets a spanning header over the columns Name 1 and Name2 as indicated by the ( ) around the text.

The Define statements with the /"" suppress the default variable label that the individual variables would otherwise contribute.

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 101 views
  • 1 like
  • 2 in conversation