Hello,
I am trying to clean character strings - I would like to pull out and keep only the characters between the first set of quotes.
Here is an example:
{"I34.0":1,"I48.0
I would like the result to be
I34.0
Thank you!
Do you mean quotes. I don't see parentheses() in your string.
data test;
string='{"I34.0":1,"I48.0';
sub=scan(string,2,'"');
run;
Use scan function taking " as delimiter.
Do you mean quotes. I don't see parentheses() in your string.
data test;
string='{"I34.0":1,"I48.0';
sub=scan(string,2,'"');
run;
Use scan function taking " as delimiter.
yes thank you!!
Assuming you mean double quotes, not parentheses,
data have;
CharString = '{"I34.0":1,"I48.0';
output;
run;
data want;
retain _RX1;
if _n_ = 1 then
_RX1 = prxparse('|"([^"]+)"|');
set have;
if prxmatch(_RX1, CharString) then
WantedString = prxposn(_RX1, 1, CharString);
run;
Tom
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.