How do I get this code to work?
if callfreqothc=""sick Person"" then callfreqothc="Sick Person";
__
49
____
388
76
This is the message I'm getting in the log:
NOTE 49-169: The meaning of an identifier after a quoted string might change in
a future SAS release. Inserting white space between a quoted
Thanks!
string and the succeeding identifier is recommended.
If you are familiar with the macro language you could use quoting functions to mask the inner quotes ... the following should work:
data want;
callfreqothc='"sick Person"';
if callfreqothc="%str(%"sick Person%")" then callfreqothc="Sick Person";
run;
The %str() function masks characters that you don't want their meaning interpreted. This needs to be supplemented with individual % signs just before each quote you want to mask
Use the dequote() function:
data test;
input string $20.;
n_string = dequote(string);
datalines;
"sick Person"
;
If you are familiar with the macro language you could use quoting functions to mask the inner quotes ... the following should work:
data want;
callfreqothc='"sick Person"';
if callfreqothc="%str(%"sick Person%")" then callfreqothc="Sick Person";
run;
The %str() function masks characters that you don't want their meaning interpreted. This needs to be supplemented with individual % signs just before each quote you want to mask
There is no need to get the macro processor involved. The SAS language already has methods to represent strings with quotes in them.
You can use different type of quotes on the outside.
if callfreqothc='"sick Person"' then callfreqothc="Sick Person";
Or double any internal quote characters that match the outside quote characters.
if callfreqothc="""sick Person""" then callfreqothc="Sick Person";
Or a bquote instead
if callfreqothc="%bquote("sick Person")" then callfreqothc="Sick Person";
Or something fancy with informat and function
callfreqothc=propcase(input(callfreqothc, $quote15.));
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.