The SAS Output Delivery System and reporting techniques

merging text in one row over 2 columns proc report ods rtf

Reply
Contributor
Posts: 37

merging text in one row over 2 columns proc report ods rtf

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

 

Super User
Posts: 13,941

Re: merging text in one row over 2 columns proc report ods rtf

Posted in reply to nirali514

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?

Super User
Posts: 10,849

Re: merging text in one row over 2 columns proc report ods rtf

Posted in reply to nirali514

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

Contributor
Posts: 37

Re: merging text in one row over 2 columns proc report ods rtf

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.

Contributor
Posts: 37

Re: merging text in one row over 2 columns proc report ods rtf

hi!

 

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

Super User
Posts: 10,849

Re: merging text in one row over 2 columns proc report ods rtf

Posted in reply to nirali514

Can you post an example ?

Super User
Posts: 10,849

Re: merging text in one row over 2 columns proc report ods rtf

Posted in reply to nirali514

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;
Contributor
Posts: 37

Re: merging text in one row over 2 columns proc report ods rtf

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.

SAS Super FREQ
Posts: 9,431

Re: merging text in one row over 2 columns proc report ods rtf

[ Edited ]
Posted in reply to nirali514

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

Ask a Question
Discussion stats
  • 8 replies
  • 306 views
  • 0 likes
  • 4 in conversation