BookmarkSubscribeRSS Feed
madhu
Calcite | Level 5
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.
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
Cynthia_sas
SAS Super FREQ
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]
Brian_Tucker
Calcite | Level 5
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 732 views
  • 0 likes
  • 4 in conversation