Hello,
I have this code to put the data I need separated by a comma. Now, what I need is a new line after the comma.
Currently, I have this
1 due to symptom1,2 due to symptom2,1 due to symptom3,3 due to symptom4,1 due to symptom5, 1 due to symptom6, and so on.. |
Solution that worked for me:
I used ods escapechar='^';
I added ^n where I want my line break. It doesn't show in the listing or dataset but t works on the rtf file and html file.
cat=catx(',^n',cat,death_reason);
You can use something like
CAT=catx(','||'0D0A'x, CAT DEATH_REASON);
Where it gets used depends on the output.
You won't see the LF in an HTML report for example.
Adding the '0D0A'x didn't work for me. I am creating rtf destination, but its all in one big line separated by commas. It doesn't add a line after commas.
If you use proc report, you can insert RTF codes with the ~R prefix.
See here.
For example:
data T;
A=catx(','||'0d0a'x , 'ABC', 'DEF');
run;
A new line WHERE? Your code seems to be just creating a character strings, not a report.
I need to use it in an ODS RTF destination.
data have;
str='1 due to symptom1,2 due to symptom2,1 due to symptom3,3 due to symptom4,1 due to symptom5, 1 due to symptom6';
run;
data want;
set have;
do _n_=1 to countw(str,',');
want=cats(scan(str,_n_,','),',');
output;
end;
run;
Thanks, I need it in the same cell. This puts a new row for each line, but I need everything in one cell.
Hi:
ODS RTF supports the ESCAPECHAR and the {newline} function. In the example below, I declared my ESCAPECHAR to be caret ^, as shown in the code and it produced the same output in both PROC PRINT and PROC REPORT.
Hope this helps,
Cynthia
@Cynthia_sas I tried escaping a new line but never found the correct syntax.
I tried \line and \par and even unicode values.
It turns out {newline} does it.
It's not easy finding the proper syntax.
Like the unicode implementation (and here) I find this confusing.
Solution that worked for me:
I used ods escapechar='^';
I added ^n where I want my line break. It doesn't show in the listing or dataset but t works on the rtf file and html file.
cat=catx(',^n',cat,death_reason);
Perfect! I just changed my code to ^newline. Thanks so much.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.