BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
psh23
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

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.

 

 

Thanks,
Suryakiran

View solution in original post

3 REPLIES 3
SuryaKiran
Meteorite | Level 14

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.

 

 

Thanks,
Suryakiran
psh23
Fluorite | Level 6

yes thank you!!

TomKari
Onyx | Level 15

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 3 replies
  • 1263 views
  • 2 likes
  • 3 in conversation