- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, all
I am using PROC REPORT, and for three columns I would like to have the cells contain multiple lines, and control where the line breaks. Here's an MS Word image of what I'm trying to get:
The only way I can seem to get this is to use a DATA step to physically create a long character variable, with my lines separated by <crlf> characters. So the first cell would be
LONGLINE = cats(Line1, '0d0a'x, Line2, '0d0a'x, Line3);
I'm far from an expert on PROC REPORT, but it seems to me there should be an easier way.
All suggestions would be appreciated!
Tom
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use escapechar instead. data have; length AllCol1Data AllCol2Data AllCol3Data $256; AllCol1Data = cats('C1Line 1 ~n C1Line 2'); AllCol2Data = cats('C2Line 1 ~n C2Line 2'); AllCol3Data = cats('C3Line 1 ~n C3Line 2 ~n C3Line 3 ~n C3Line 4'); output; run; ods escapechar='~'; proc report data=have nowd; columns AllCol1Data AllCol2Data AllCol3Data; define AllCol1Data / display "Column 1"; define AllCol2Data / display "Column 2"; define AllCol3Data / display "Column 3"; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please post a sample data and criteria for the break and wanted output.
Have you tried using proc report - if positive, post your code and output;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Shmuel
Here's the SAS code that I am using, with the <crlf> characters. I really think there should be a way to do this without needing such a technical approach. Let me know what you think.
Thanks,
Tom
data have;
length AllCol1Data AllCol2Data AllCol3Data $256;
AllCol1Data = cats('C1Line 1', '0d0a'x, 'C1Line 2');
AllCol2Data = cats('C2Line 1', '0d0a'x, 'C2Line 2');
AllCol3Data = cats('C3Line 1', '0d0a'x, 'C3Line 2', '0d0a'x, 'C3Line 3', '0d0a'x, 'C3Line 4');
output;
run;
proc report data=have nowd;
columns AllCol1Data AllCol2Data AllCol3Data;
define AllCol1Data / display "Column 1";
define AllCol2Data / display "Column 2";
define AllCol3Data / display "Column 3";
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Now that I understand what are you looking for - it was a chalenge, for me, to try and find the solution.
I'm not sure it is possible but I have found some options, which may do the work when lines are realy long.
See next link:
It seems that next code, maybe will do the work:
proc report data have wrap named;
columns ....
define <col name> / display <label> width=25; /* for 25 characters column width */
....
run;
With the sample data I could not come to the wanted output.
Maybe someone else in the forum can help more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I think I mislead you with the contents of the variables. They have nothing to do with which row and column they are in, I just used those because I wanted to not disclose client data. Here's a better example. Given:
data have;
length AllCol1Data AllCol2Data AllCol3Data $256;
input AllCol1Data & AllCol2Data & AllCol3Data &;
cards;
A AAAA/BB/C/DD DDDDD EEE/FF FFF FF GGGGGG GG/HH
run;
I would like to see a PROC REPORT result of:
(Note that I don't care that the line end statement is a slash; any odd character will do)
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You have just changed the breaking column delimiter from '0d0a'x to '/'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ideally I would want the delimiter to be just a normal character, instead of using a <crlf> combination. But I can't find any way to make it work.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use escapechar instead. data have; length AllCol1Data AllCol2Data AllCol3Data $256; AllCol1Data = cats('C1Line 1 ~n C1Line 2'); AllCol2Data = cats('C2Line 1 ~n C2Line 2'); AllCol3Data = cats('C3Line 1 ~n C3Line 2 ~n C3Line 3 ~n C3Line 4'); output; run; ods escapechar='~'; proc report data=have nowd; columns AllCol1Data AllCol2Data AllCol3Data; define AllCol1Data / display "Column 1"; define AllCol2Data / display "Column 2"; define AllCol3Data / display "Column 3"; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @Ksharp, and thanks!
I must admit, I thought there would be something in the PROC REPORT syntax that would do this, but I guess there isn't.
Anyway, this is a much more elegant solution, and I'm completely happy giving this to my client as a suggested approach. Thanks so much!
Keep an eye out for my next expected problem...it'll be under the ODS community.
Tom