Hi all
I have some values containing text which can be in single or double quote marks. I would like to remove the quote marks plus the text inside
e.g.
have:
VAR1
hello "dog" is my pet
just text
hi 'people' how are you
want:
VAR1
hello is my pet
just text
hi how are you
thanks for your help
One way
data have;
input var1 $ 1 - 25;
datalines;
hello "dog" is my pet
just text
hi 'people' how are you
;
data want;
set have;
var1 = compbl(prxchange('s/".*"//', -1, prxchange("s/'.*'//", -1, var1)));
run;
One way
data have;
input var1 $ 1 - 25;
datalines;
hello "dog" is my pet
just text
hi 'people' how are you
;
data want;
set have;
var1 = compbl(prxchange('s/".*"//', -1, prxchange("s/'.*'//", -1, var1)));
run;
Thanks for helping..it works perfectly
Anytime 🙂
Peter.C
If there were multiple quote characters, your code would get wrong result.
Like this sort of data.
data have;
input var1 $ 1 - 40;
datalines;
hello "dog" is my pet "dog" xxx
just text
hi 'people' how are you 'people'
; data want; set have; var1 =prxchange("s/'.*?'|"".*?""//", -1, var1); run;
data have; input var1 $ 1 - 40; datalines; hello "dog" is my pet "dog" xxx just text hi 'people' how are you 'people' ;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.