BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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:

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

Contact :pqr
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
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
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.

cynthia
deleted_user
Not applicable
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.
Cynthia_sas
SAS Super FREQ
Hi:
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:
http://support.sas.com/forums/thread.jspa?messageID=7470ᴮ
http://support.sas.com/forums/thread.jspa?messageID=6397᣽
http://support.sas.com/forums/thread.jspa?messageID=7505ᵑ (#2)
http://support.sas.com/forums/thread.jspa?messageID=7468ᴬ
http://support.sas.com/forums/thread.jspa?messageID=7403ᳫ

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:
[pre]
ODS ESCAPECHAR='~';
[/pre]

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.

cynthia
[pre]
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,
put(age,3.0),slash,
put(height,6.2),slash,
put(weight,6.2));
endcomp;

** 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,
put(age,3.0),linefeed,
put(height,6.2),linefeed,
put(weight,6.2));
endcomp;

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

[/pre]

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 980 views
  • 0 likes
  • 2 in conversation