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
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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