@AshleyBright:
Forget Notepad. When you copy-and-paste into it, what you see may not be what you have in your SAS variable.
Instead, locate the observation number with the variable value you want to investigate. Suppose this number is 123, your variable in question is called S, and the data set is called HAVE. Run the step:
data _null_ ;
obs_num = 123 ;
set have point = obs_num ;
do pos = 1 to length (s) ;
b = char (s, pos) ;
put b=$hex2. b= pos= ;
end ;
stop ;
run ;
and look at the log. For the first 14 positions of the string you've exemplified here, the step will print:
b=22 b=" pos=1 b=22 b=" pos=2 b=22 b=" pos=3 b=74 b=t pos=4 b=65 b=e pos=5 b=73 b=s pos=6 b=74 b=t pos=7 b=3A b=: pos=8 b=7B b={ pos=9 b=22 b=" pos=10 b=22 b=" pos=11 b=22 b=" pos=12 b=22 b=" pos=13 b=74 b=t pos=14
This will represent the true character content of your string, and you'll be able to determine whether the "quotes" you see in the viewer are really quotes or something else and/or if there're some "hidden" characters you can't see. If some characters that look to you like quotes are in reality other characters, such as not-printables, note their hex values in the log and use them as hex literals with the COMPRESS function to kill them.
Now if you determine from the log that they are real double quotes, only multiplied for some reason, and you want to collapse any number of consecutive double-quotes to a single double-quote, run:
data want ;
set have ;
do while (find (s, '""')) ;
s = tranwrd (s, '""', '"') ;
end ;
run ;
Or, if you want to leave no more than 2 consecutive double-quotes in the value of your variable, change the DO loop to:
do while (find (s, '"""')) ;
s = tranwrd (s, '"""', '""') ;
end ;
Anything is possible if you really know what's in your string and what and in which manner you want to change (as long as there's a pattern). But looking at the SAS data after moving them out of the SAS system, especially by copying and pasting, is error-prone.
Kind regards
Paul D.
... View more