Hi
I need to remove [" from the word say ["Mumbai"]. I am able to remove the [ and ] using functions like Tranwrd however I want to know how to remove the " as the function syntax itself has an opening " and a closing " and I am unable to remove the " (which is itself a part of the input). SAS does not seem to be accepting the " within the opening " and closing ". I will appreciate any help.
Thanks
Manish
'
When you need to remove characters, I would use the character functions not the word ones. eg SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition PRX (perl regular strings) are also an option. Within SAS the definition of a string is a basic concept but lost a clear reference. Single quotes (no macro expansion) double quotes (with macro expansion can be used to mark a string begin/end . Repeating a quote is masking the meaning. See: SAS(R) 9.4 Language Reference: Concepts, Third Edition example on Tom's
Hello,
One solution:
data have;
a='["Mumbai"]';
b=compress(a,'"[]');
run;
data have;
a='["Mumbai"]';
b=Tranwrd(a,'["','');
c=Tranwrd(b,'"]','');
run;
hi mjaitly
you can use compress with the "keep" option to select all letters from the original text,
because you have capital letters as well I recommend the following syntax :
data have;
have='["New York"]';
need=compress(have,'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'K');
any_other_word='["or any other word"]';
any_other_word1=compress(any_other_word,'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'K');
run;
this way you can deal with capital letters and blanks you want to keep, and get rid of all other punctuations symbols .
If you want to include a quote inside of a quoted string you need to double up the quote character. Note that you can also convert from using using double quotes to single quotes.
Examples:
" ""Mumbai"" "
' "Mumbai" '
"Don't"
'Don''t'
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: