Desktop productivity for business analysts and programmers

To display columns in multiple lines

Not applicable
Posts: 0

To display columns in multiple lines

I have a report in which I have to display columns in multiple lines.
I have fields like Address1..Address4 and contact details and name of the customer like this I have around 30 columns which i want to display for each User =xxxx in 5 to 6 lines.

For example:

Acc_number & name=1234 abc Status=0
Statement Address : 123,fagda,hdh Invoice Address : 123,fagda,hdh
ncnvn, ncnvn,
gsfjjf, gsfjjf,
tryeur. tryeur.

Contact Smiley Tongueqr
Telephone :23143
fax: 455535

In The above layout you can see I have 4 address field which i want to combine in one column .

How to get this type of report through SAS Enterprise Guide
Posts: 9,431

Re: To display columns in multiple lines

Posted in reply to deleted_user
You CAN get that type of report from SAS, however, you will have to use program code (in a code node in Enterprise Guide).

Basically, you'll have to use a DATA step program. The newest syntax for FILE and PUT statements within the DATA step program works with ODS and produces ODS destination report output in LISTING, ODS HTML, ODS RTF and ODS PDF. These documentation topics will be the most useful to you:
"Dictionary of ODS Language Statements"
"FILE Statement for ODS"
"PUT Statement for ODS"
"Output Delivery System and the DATA Step"

There is also some older ("classic") syntax for FILE and PUT statements within the DATA step program for LISTING destination output ONLY:
"Understanding and Customizing SAS Output: The Basics"
"Controlling the Appearance of Pages"
"Writing Lines to the SAS Log or to an Output File"
"Writing to an Output File"

No matter which of these methods you choose, you will still have to use an EG code node to write and submit your report program.

Not applicable
Posts: 0

Re: To display columns in multiple lines

Posted in reply to Cynthia_sas
Thnx,I have no problem to use EG code node.
But Can you can tell me whether I can use Proc Report to get this output or can you give me some example.
Posts: 9,431

Re: To display columns in multiple lines

Posted in reply to deleted_user
Yes, you CAN use PROC REPORT. However, if you want to display both character and numeric data values in ONE column, then you have to turn any numeric variable values into character strings with the PUT statement. You are better off if ALL your data are character variables, because then you can just concatenate them together without worrying about converting numeric variables to character strings.

Next, you have the issue of how to break the line.

In the LISTING destination with SAS and PROC REPORT, you can use the FLOW option on the DEFINE statement to cause text within data cell to wrap. However, even if you use FLOW and the / (the default line break character) in PROC REPORT, you may find that information is not lined up the way you want or that the line still breaks awkwardly, depending on the WIDTH you use.
Examples of using FLOW (and CELLWIDTH) can be found in these previous forum postings:ᴮ᣽ᵑ (#2)ᴬᳫ

For ODS destinations, like HTML, RTF and PDF, you can use the ODS ESCAPECHAR + n to insert a line break/line feed that is respected in these destinations. So, by this I mean:

If the ESCAPECHAR is set to tilde (~) then ~n is the string that will cause a line break in RTF, PDF and HTML (but NOT in the LISTING destination).

This example uses SASHELP.CLASS and shows the use of WRAP and FLOW with the / for the LISTING destination and also shows the use of ODS ESCAPECHAR for other ODS destinations.

ods listing;

ods html file='c:\temp\multi_line.html' style=egdefault;
ods escapechar='~';

proc report data=sashelp.class nowd ls=256 nocenter split='/';
title 'Multi_Line with PROC REPORT -- FLOW option ignored for ODS';
title2 'So use ESCCHAR + n for ODS destinations other than LISTING';
column name sex age height weight newvar odsvar;

** These variables are all NOPRINT because they are only going;
** to be used to build the NEWVAR and ODSVAR report items.;
define name/ order noprint;
define sex /display noprint;
define age /display noprint;
define height /display noprint;
define weight /display noprint;

define newvar /computed flow width=20 'FLOW/Works in/LISTING';
define odsvar /computed f=$200. 'Esc+n/Works in/ODS';

** NEWVAR will format well in LISTING dest, depending on WIDTH and FLOW;
compute newvar / character length=200;
slash = '/';
newvar = cats(name,slash,sex,slash,

** ODSVAR will format well in RTF, PDF and HTML, since it uses ODS ESCAPECHAR string for line feed;
compute odsvar / character length=200;
linefeed = '~n';
odsvar = cats(name,linefeed,sex,linefeed,

break after name /skip;
compute after name;
line ' ';
ods html close;

Ask a Question
Discussion stats
  • 3 replies
  • 2 in conversation