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

I have a dataset that has ^ in the data, 1x10^3.

My escapechar is '^'.

Is there a way to mask the '^' in the data?

I know I can reset the escape character to something else, but would like to know if there is a function of some sort to make it read in the entire value, ignoring the escape character.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi, the easiest thing to do is to change your escape character to something else. Change it to something like
ods escapechar='~';
or some other character like the #.
Reading the data should be OK. Take a look at this quick test:

Cynthia_sas_0-1640298194137.png


It's when you go to use ODS to display the data that ODS ESCAPECHAR can cause you issues... as shown in this PROC PRINT output:

Cynthia_sas_1-1640298234043.png

The data is being read correctly. Why can't you change the ESCAPECHAR before your report step?
Cynthia

View solution in original post

6 REPLIES 6
SASKiwi
PROC Star

So your data is in an external file you are trying to read into SAS or is it already in a SAS dataset you have read from an external file? The usual approach is to replace unprintable characters like escape with blanks. This can be done with the TRANSLATE function as you are reading your data in or during post-processing.

Cynthia_sas
SAS Super FREQ

Hi, the easiest thing to do is to change your escape character to something else. Change it to something like
ods escapechar='~';
or some other character like the #.
Reading the data should be OK. Take a look at this quick test:

Cynthia_sas_0-1640298194137.png


It's when you go to use ODS to display the data that ODS ESCAPECHAR can cause you issues... as shown in this PROC PRINT output:

Cynthia_sas_1-1640298234043.png

The data is being read correctly. Why can't you change the ESCAPECHAR before your report step?
Cynthia

jtcowder
Fluorite | Level 6

That is what I ended up doing.

 

Thank you.

jtcowder
Fluorite | Level 6

To answer the second part of your post :

the footer has "page x of y" in it, and that was called from a driver file.

Changing the escapechar just before the report made the paging not present correctly.

 

I went back to the common driver file and changed the escapechar there.  Now I will have to check other code that used the "^" escapechar to add superscripts to some headings and change it there as well.

Tom
Super User Tom
Super User

Why are you using ^ as the escapechar for ODS if you know the text you want to display includes it?

Use a different escape character for ODS.

jtcowder
Fluorite | Level 6

In part, because this data set had not been used before, so when the initial code was written, none of the data sets had '^' in them, which was what being used as the escapechar.

 

After producing something like 40 outputs, they requested similar tables on a data set with data that read 1x10^3 in one field.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 1187 views
  • 0 likes
  • 4 in conversation