SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

cleaning character string

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

cleaning character string

[ Edited ]

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!


Accepted Solutions
Solution
3 weeks ago
Valued Guide
Posts: 560

Re: cleaning character string

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


All Replies
Solution
3 weeks ago
Valued Guide
Posts: 560

Re: cleaning character string

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
Contributor
Posts: 25

Re: cleaning character string

Posted in reply to SuryaKiran

yes thank you!!

PROC Star
Posts: 1,288

Re: cleaning character string

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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