BookmarkSubscribeRSS Feed
sas_Forum
Calcite | Level 5

Hi i am having data like this

"good work done <123.http> by <lpo;"340> nani <//,89:789> kumar

now i wnat to remove the data in between these symbols < >

output :

"good work done by nani kumar

5 REPLIES 5
FriedEgg
SAS Employee

Take a look at this similar post, it should provide your answer.

http://communities.sas.com/message/103590#103590

art297
Opal | Level 21

And, if you're not used to using regular expressions, the following is an example using your data with the code suggested in that post:

data have;

  informat string $80.;

  input string &;

  cards4;

good work done <123.http> by <lpo;"340> nani <//,89:789> kumar

now <dfkljdfj> is the <jkfiuoiewurk> time for it

;;;;

data want (drop=rx);

  set have;

  if _n_ eq 1 then rx = prxparse('s/<[^>]*>//');

  retain rx;

  string = prxchange(rx,100,string);

run;

sas_Forum
Calcite | Level 5

Hi art can u tell me what

prxparse('s/<[^>]*>//');  is this means like 's/<[^>]*>//'  and what prxchange will do ,can you expalin me

DLing
Obsidian | Level 7

SAS has excellent documentation:

http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p06i7305izs...

and there are lots of SGF papers on regular expressions and SAS.  Suggest you go there first as it is available 24/7.

FriedEgg
SAS Employee

DLing is correct about reference the documentation that is available.  I will explain that regular expression briefly.

s/<[^>]*>//

substitute, look for < that is not immediately followed by > but has any other string inbetween another >, replace with nil

Also by using the prxdebug function you will get nice information in your log about what it is doing, can help you understand, maybe.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 752 views
  • 0 likes
  • 4 in conversation