BookmarkSubscribeRSS Feed
nirali514
Obsidian | Level 7

Hello! Is there a way to merge text in cells in a proc report?

 

col1     col2

1          1.5

2          2.5

3          3.5

I'd like the text to

span across like this

4          4.5

5          5.5

 

8 REPLIES 8
ballardw
Super User

What have you tried so far?

 

One way I can think of is to add variable to group your responses but don't display it. The you can use break or rbreak. But where does that text come from? Is it going to change for each group? Is it in a variable in the data set?

Ksharp
Super User

Here is an example .

 


data have;
input group  col1     col2;
cards;
1 1          1.5
1 2          2.5
1 3          3.5
2 4          4.5
2 5          5.5
;
run;

ods escapechar='~';
proc report data=have nowd;
column group col1 col2;
define group/group noprint;
define col1/display;
compute after group;
if group=2 then len=0;
 else len=100;
temp="I'd like the text to ~n span across like this" ;
line @1 temp $varying200. len;
endcomp;
run;

x.png

nirali514
Obsidian | Level 7

Thank you! This works. However, if there are muliple sections, would it be possible to have different text? So say in between group 2 and 3 there is different text.

nirali514
Obsidian | Level 7

hi!

 

Do you have any other ideas on how to add a second temp variable after group 2?

Ksharp
Super User

Can you post an example ?

Ksharp
Super User

If I understood what you mean.

 


data have;
input group  col1     col2;
cards;
1 1          1.5
1 2          2.5
1 3          3.5
2 4          4.5
2 5          5.5
;
run;

ods escapechar='~';
proc report data=have nowd;
column group col1 col2;
define group/group noprint;
define col1/display;
compute after group;
if group=1 then temp="I'd like the text to ~n span across like this" ;
 else if group=2 then  temp="Another Line ~n span across like this" ;
len=100;
line @1 temp $varying200. len;
endcomp;
run;
nirali514
Obsidian | Level 7

Thanks you! This works, however is there a way to have longer text? Suppose the text is longer than 262 characters. All the characters don't seem to show with $varying200.

Cynthia_sas
Diamond | Level 26

Then make it varying300. or use a LENGTH variable, as shown in Ksharp's original program.
len = length(temp);
line temp $varying. len;

(the @1 is for the LISTING output and you don't need the 200 or even 300 if you find the correct length of the TEMP variable)

cynthia

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
  • 8 replies
  • 3890 views
  • 0 likes
  • 4 in conversation