The SAS Output Delivery System and reporting techniques

Print the back slash using proc report.

Reply
Occasional Contributor
Posts: 7

Print the back slash using proc report.

Hi,

I have a  variable content value as a test\reference. I want to print that value in RTF but instead of print slash (\) its prints some symbol between test and refernce. Does any one help to print the back slash. I am using proc report.

Thanks

Super Contributor
Posts: 543

Re: Print the back slash using proc report.

When I try this (see code below, which is just a sample code to get an idea for myself) the "\" print in the rtf document.

Could you share the code?

ods rtf file = "back_slash.rtf";

proc report nowd data=sashelp.class ;

column age weight;

define age/display "Age\over nothing";

define weight /display;

run;

ods rtf close;

Let me know if it works?

Thanks and good luck!

Anca.

Occasional Contributor
Posts: 7

Re: Print the back slash using proc report.

Posted in reply to AncaTilea


Thanks Anca, I do'nt need it for header. For e.g. you have age variable and values as 23\Y, 45\Y in dataset.

I used the same syntax but 23\Y is not reflecting in RTF. instead of \ its showing sybol shaped Y.

Sorry if I was not clear earlier.

Thanks,

Priyanka

Super Contributor
Posts: 543

Re: Print the back slash using proc report.

OK,

Please see attached.

data temp;

length new_age $5.;

set sashelp.class;

if age = 12 then new_age = "12\y";

    else new_age = age;

run;

ods rtf file = "back_slash.rtf";

proc report nowd data=temp;

column new_age weight;

define new_age/display "Age\over nothing";

define weight /display;

run;

ods rtf close;

Would share the code, please? (with some fake data)

Thanks.

Anca.

PS: I had to attach it as .PDF because it wouldn't allow me to attach .RTF file.

Occasional Contributor
Posts: 7

Re: Print the back slash using proc report.

Posted in reply to AncaTilea

Hi,

Please see the attached file for code and output.

Super Contributor
Posts: 543

Re: Print the back slash using proc report.

I see.

I get it to work.

can you close/open SAS to make sure you have no other options set?

I added an ods pdf file = "c\pk.pdf";

...code...

ods pdf close;

and it worked (see attached);

hmmmm....

I try to think what else may cause this?

Super Contributor
Posts: 266

Re: Print the back slash using proc report.

Posted in reply to AncaTilea

Hi , i want to display / in my header, like "Sales/Year"

but sas doing it as  "Sales

                             Year"

how i can set my display??

Super User
Super User
Posts: 7,977

Re: Print the back slash using proc report.

Hi,

Check:

What is your escape char set to, e.g.

ods escapechar='^';

In your proc report statement do you have split= set, e.g.

proc report data=mydata split='~';

In your initial PDF, it looks like you have a special language set loaded, something in your intialisation?

SAS Super FREQ
Posts: 8,868

Re: Print the back slash using proc report.

Hi,

My suggestion is that the original poster (p9jain) work with Tech Support. When I run either your code or the OP code in SAS 9.4, I correctly see the \ in the output. While it is true that the \ generally has special meaning to RTF, such as when using RTF control strings directly in the output, my suspicion is something having to do with fonts in the OP version of Microsoft Word instead of something with SAS. When I run either code, as I said, using SAS 9.4 and Word 2013, I do see the back slash in the output. See the attached screen shots. My font, as set by the STYLE template for RTF  (styles.rtf) is using Times New Roman. It's better to compare apples to apples. If the OP wants RTF, then comparing to PDF or creating output to PDF is not a fair test. PDF might have different default fonts than RTF. If the OP wants RTF, then the RTF examples should be the ones compared.

cynthia


what_rtf_looks_like_sas94.pngrun_OP_code_what_rtf_sas94.png
Ask a Question
Discussion stats
  • 8 replies
  • 1443 views
  • 0 likes
  • 5 in conversation