The SAS Output Delivery System and reporting techniques

Folding data into one column

Posts: 27

Folding data into one column


1.I am trying to fold data available in 3 variables(AETERM, AEDECOD, AEBODSYS) into one column (AEDIAGNOSIS) in a report. How can I accomplish this task in RTF/PDF.

2. Can any one help me with a code that does the function of 'ENTER' key in SAS ODS/RTF.
Super Contributor
Super Contributor
Posts: 3,176

Re: Folding data into one column

Presuming you already have these "variables" contained in a SAS file, what you want to accomplish can be done with a DATA step, and also using SAS ODS with either RTF or PDF output. Your SAS programming experience level is uncertain from your post. Also, your SAS version and OS environment is also an unknown. These pieces of information are important with most SAS forum posts / questions.

Some suggested reading on the DATA step wth assigning (concatenate) variables using SAS function CATT / CATX / CATS, and also the ODS facilities within SAS to direct your DATA step or PROC PRINT output to a suitable output file, as discussed in your post.

Scott Barry
SBBWorks, Inc.

SAS(R) 9.2 Language Reference: Concepts - DATA Step Processing

Step-by-Step Programming with Base SAS(R) Software - What is the SAS System? -- several sub-sections on data handling and generating reports:

SUGI 31 paper:
Paper 247-31
An Introduction to SAS® Character Functions, Ronald Cody, Ed.D. -- discussion on CATX, CATT for concatenation
Posts: 9,368

Re: Folding data into one column

I'm not sure what you mean by "fold data ... into one column". I think you mean to concatenate or stack variables (which would normally appear in separate columns) into one column. There are 3 methods of doing this: 1) PROC REPORT COMPUTE block; or 2) DATA step program or 3) TABLE template -- depending on your procedure of choice. See the program example below, it illustrates the PROC REPORT technique.

Again, not sure what you mean by the "Enter" key??? Do you mean that you want to insert a line break within the values displayed in a column on a report??? Inserting a LINE FEED (or NEW LINE or CARRIAGE RETURN) character can be accomplished with ODS ESCAPECHAR techniques. Again, see the program example below (which shows the use of ODS ESCAPECHAR='^') and this paper:


ods rtf file='mult_col.rtf';
ods pdf file='mult_col.pdf';
ods escapechar='^';

proc report data=sashelp.class nowd;
column name sex age height show3 weight;
define name / order;
define sex / display noprint;
define age / display noprint;
define height / display noprint;
define show3 / computed 'Computed Show3';
define weight / display;
compute show3 / character length=50;
length tempvar $50;
tempvar = 'Gender: '||trim(sex)||' -- Age: '||put(age,2.0)||'^n'||
'Height: '||left(put(height,6.1));
show3 = tempvar;
ods _all_ close;

New Contributor
Posts: 3

Re: Folding data into one column

Posted in reply to Cynthia_sas

We accomplish this with the CATX function and use of an escape character as mentioned above.


The final column in the REPORT looks like

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