BookmarkSubscribeRSS Feed
pavansvc
Fluorite | Level 6

HI I have been trying to wrap text in the ods pdf file but I could not get it.

 

proc report data=ae split='|' headskip missing style(report)={ rules=none frame=void cellpadding=2};
col term stdtc_dy endtc_dy aeser ser_evnt aeadmdtc aedisdtc aesev aerela aeacn aerel3 aeacn2 aerel4 aeacn3 aerel5 aeacn4 aeout;

define term / 'System Organ Class /^nPreferred Term /^nEvent Name' style(column)={cellwidth=2.10 in just=l indent=1in} style(header)={textdecoration=underline just=l};

run;

 

I was trying by giving as indent = 1 in but no use. The desired output should be as follows.

 

Nervous System /

   Seizure /

   Seizure

From second line I want it should be little right compared to first line.

Any help please!

 

Thanks!

7 REPLIES 7
ballardw
Super User

Wrap text where? Column heading, row heading, column of values (variable), specific cells, specific rows?

 

Your example desired text is sort of without context. We don't know what variable would hold values and you are showing text that doesn't appear in a define statement or column heading so it is hard to guess what is supposed to build that text.

 

It will likely help in the long run to also provide some example data. Example data should be in the form of a data step so we do not have to guess which things that look like numbers but are character in your data are such.

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

pavansvc
Fluorite | Level 6

data ae;
input ATCClass $1-22 Drug $23-32 Medname $33-42;
datalines;
SOFTENERS, EMOLLIENTS DOCUSATE Docusate
HYDANTOIN DERIVATIVES PHENYTOIN Phenytoin
run;

data ae1;
length term $110;
set ae;
term=catx("/^n ",ATCClass,Drug,Medname);
keep term;
run;

title1 j=c "How to wrap the text in the column header and also values";
ods escapechar='^';
ods listing close;
ods pdf file="\\tgenbkup\users\PSanam\Desktop\New folder\test.pdf" style=styles.tr_tnr1 NOBOOKMARKGEN;

proc report data=ae1 split='|' headskip missing style(report)={rules=none frame=void cellpadding=2};
column term;

define term / 'ATC Class / |Drug / |Medication Name' style(column)={cellwidth=5 in just=l} style(header)={textdecoration=underline just=l};

compute before term;
line put " ";
endcomp;


run;
ods pdf close;
ods listing;

 

Also, I have attached the desired output with this post

 

Capture.JPG

andreas_lds
Jade | Level 19

@pavansvc wrote:

data ae;
input ATCClass $1-22 Drug $23-32 Medname $33-42;
datalines;
SOFTENERS, EMOLLIENTS DOCUSATE Docusate
HYDANTOIN DERIVATIVES PHENYTOIN Phenytoin
run;

data ae1;
length term $110;
set ae;
term=catx("/^n ",ATCClass,Drug,Medname);
keep term;
run;

title1 j=c "How to wrap the text in the column header and also values";
ods escapechar='^';
ods listing close;
ods pdf file="\\tgenbkup\users\PSanam\Desktop\New folder\test.pdf" style=styles.tr_tnr1 NOBOOKMARKGEN;

proc report data=ae1 split='|' headskip missing style(report)={rules=none frame=void cellpadding=2};
column term;

define term / 'ATC Class / |Drug / |Medication Name' style(column)={cellwidth=5 in just=l} style(header)={textdecoration=underline just=l};

compute before term;
line put " ";
endcomp;


run;
ods pdf close;
ods listing;

 

Also, I have attached the desired output with this post

 

 


Maybe start by fixing errors:

ERROR: You can only BREAK on GROUPing and ORDERing variables.

 

And please use the running-man-icon to post code!

pavansvc
Fluorite | Level 6
data ae1;
   input ATCClass $1-22 Drug $23-32 Medname $33-42;
   length term $110;
   term=catx("/^n ",ATCClass,Drug,Medname);
   keep term;

datalines;
SOFTENERS, EMOLLIENTS DOCUSATE  Docusate
HYDANTOIN DERIVATIVES PHENYTOIN Phenytoin
run;

title1 j=c "How to wrap the text in the column header and also values";
ods escapechar='^';
ods listing close;
ods pdf file="\\tgenbkup\users\PSanam\Desktop\New folder\test.pdf" style=styles.tr_tnr1 NOBOOKMARKGEN;

proc report data=ae1 split='|' headskip missing style(report)={rules=none frame=void cellpadding=2};
column term;

define term / 'ATC Class / |Drug / |Medication Name' order style(column)={cellwidth=5 in just=l} style(header)={textdecoration=underline just=l};

compute before term;
line put " ";
endcomp;


run;
ods pdf close;
ods listing;

Please help me how to get the output as follows:

 

ATC Class /
   Drug /
   Medication Name
HYDANTOIN DERIVATIVES/
   PHENYTOIN/
   Phenytoin


SOFTENERS, EMOLLIENTS/
   DOCUSATE/
   Docusate

ballardw
Super User

Please copy the code you pasted to read the example data, paste into your editor, run the code and see if the value is as desired.

 

If when you wrote it the Medname=Docusate was complete it was no longer so after pasting the code into the forum.

The start of "Docusate" in your post starts in column 32. So the value for the first record was:

SOFTENERS, EMOLLIENTS/^n DOCUSATE D/^n ocusate

when I run your code.

 

The message windows will reformat text, often removing "white space". Which shifts columns around to where things sometimes will not run as pasted. Also the font is proportional so you cannot see that the text for the Medname does not align. Which is why we say to paste the code in a code box opened with either the {I} or the "running man".

Also you do not need a separate data step for your example:

data ae1;
   input ATCClass $1-22 Drug $23-32 Medname $33-42;
   length term $110;
   term=catx("/^n ",ATCClass,Drug,Medname);
   keep term;

datalines;
SOFTENERS, EMOLLIENTS DOCUSATE  Docusate
HYDANTOIN DERIVATIVES PHENYTOIN Phenytoin
run;

You can manipulate values read in the same step you read them. Note that in the above code box you can easily see that the Medname values start in the same column and the ATCClass end in the same column.

pavansvc
Fluorite | Level 6

Thanks for the reply and correcting me. Actually I am working and need to fix the issue. I was in hurry, so there are few errors in creating my sample code.

I want to indent or wrap the text in the ods pdf as follows. Actually this can be done in ods rtf by giving "\pnhang\fi-125\li125'" in define statement but its not working for ods pdf.

 

SOFTENERS, EMOLLIENTS/
   DOCUSATE/
   Docusate

 

HYDANTOIN DERIVATIVES/
   PHENYTOIN/
   Phenytoin

 

Thanks!

Cynthia_sas
SAS Super FREQ
Hi:
RTF control strings will not work with the ODS PDF destination.
Cynthia

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2857 views
  • 0 likes
  • 4 in conversation