BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ddutton325
Fluorite | Level 6

Hi folks,

I have search high and low in the Doc and cannot find anything about using the ODS Escapecharacter in strings followed by a single character, instead of one of the escapecharacter functions inside {---}.  And yet, I know that ^n (or whatever escape character you are using) works to give a new line, just as ^{newline} would.   Are there any other single characters that can be used in such a way, and if so, where are they documented?  

Thanks,

Donna

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
The single character ESCAPECHAR that you mention was used for a LINEFEED or RETURN in the version of ODS prior to SAS 9.2. The older version of syntax is not guaranteed to work in all the destinations.
If you look for some of the older user group papers on ODS ESCAPECHAR, including my old 2007 paper "Funny ^Stuff~ in My Code", https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/099-2007.pdf you can see some of the original syntax. But even back then, I showed the newer syntax that was on the way with SAS 9.2. However, just be aware of the fact that the new "function" style of ODS ESCAPECHAR replaced that original style.
Cynthia

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

You can use almost any character you want.  Just tell SAS which one you want to use with the ODS ESCAPECHAR statement.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/odsug/p11xia2ltavr8ln17srq8vn4rnqc.htm

 

ddutton325
Fluorite | Level 6

no, sorry Tom, you misunderstood me.  I know how to change the default '^' to whatever I want it to be.  My question is about the 'n' which follows the escape character, which is what results in the new line.  Are there other commands besides this 'n'? Are where is it (or where are they) documented. 

Donna

Tom
Super User Tom
Super User

Not sure.  There used to be some cheat sheets for ODS, perhaps something is written there.

 

You could try running an experiment.

data test;
 length code 8 char $1 odschar $2 ;
 format code hex2. ;
 do code = rank(' ') to rank('~');
   char = byte(code);
   odschar= '^'||char;
   output;
 end;
run;
ods escapechar='^';
proc print;
run;

Looks to me like it did something strange with: hyphen, 0 to 9, P, underscore, a, h, m, n, p, w and z.

Cynthia_sas
SAS Super FREQ
Hi:
The single character ESCAPECHAR that you mention was used for a LINEFEED or RETURN in the version of ODS prior to SAS 9.2. The older version of syntax is not guaranteed to work in all the destinations.
If you look for some of the older user group papers on ODS ESCAPECHAR, including my old 2007 paper "Funny ^Stuff~ in My Code", https://support.sas.com/resources/papers/proceedings/proceedings/forum2007/099-2007.pdf you can see some of the original syntax. But even back then, I showed the newer syntax that was on the way with SAS 9.2. However, just be aware of the fact that the new "function" style of ODS ESCAPECHAR replaced that original style.
Cynthia
ddutton325
Fluorite | Level 6

Thanks so much Cynthia!  That explains why I couldn't find it in the documentation.  I shall spread the word that we should modernize our code to use the current function-style syntax.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 574 views
  • 2 likes
  • 3 in conversation