The SAS Output Delivery System and reporting techniques

Folding data into one column

Reply
Contributor
Posts: 27

Folding data into one column

Hi,

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,174

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
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001281588.htm

Step-by-Step Programming with Base SAS(R) Software - What is the SAS System? -- several sub-sections on data handling and generating reports:
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001310736.htm

SUGI 31 paper:
Paper 247-31
An Introduction to SAS® Character Functions, Ronald Cody, Ed.D.
http://www2.sas.com/proceedings/sugi31/247-31.pdf -- discussion on CATX, CATT for concatenation
SAS Super FREQ
Posts: 8,744

Re: Folding data into one column

Hi:
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:
http://www2.sas.com/proceedings/forum2007/099-2007.pdf

cynthia

[pre]
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;
endcomp;
run;
ods _all_ close;

[/pre]
New Contributor
Posts: 3

Re: Folding data into one column

Hi,

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

VT_PT_SOC=CATX("/~n",AETERM,MEDPT,SOC);
ODS ESCAPECHAR="~";

The final column in the REPORT looks like
AETERM/
MEDPT/
SOC

Brian
Ask a Question
Discussion stats
  • 3 replies
  • 192 views
  • 0 likes
  • 4 in conversation