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
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?
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;
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.
hi!
Do you have any other ideas on how to add a second temp variable after group 2?
Can you post an example ?
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;
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.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.