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

I have below text data

"If  IsEqualTo Inclusion 1 then... set datapoint value for ILIST in Inclusion Criteria to LIST #1 - The subject is a boy or girl, aged ≥7 and <12years (patients who turn 12 years during the study will be allowed to continue in the game)., and execute the ""Return True"" custom function".

 

In this text i need to extract "The subject is a boy or girl, aged ≥7 and <12years (patients who turn 12 years during the study will be allowed to continue in the game)"  i.e whenever it starts with "-" and ends with ".," then i need the text in between.

 

Any help

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

If your logic is acurate then that is simple:

/* Gets all text from - */
inter=substr(have,index(have,"-"));
/* gets all text up to . */
want=substr(inter,1,index(inter,"."));

Assumes both are present etc.

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

If your logic is acurate then that is simple:

/* Gets all text from - */
inter=substr(have,index(have,"-"));
/* gets all text up to . */
want=substr(inter,1,index(inter,"."));

Assumes both are present etc.

Clash
Obsidian | Level 7

HI!

 

If your text is in a variable called "text", then this would work --> 

want = scan(scan(text,2,'-'),1,'.') ;

 

Best regards,

 

Claes

gamotte
Rhodochrosite | Level 12

Hello,

 

A solution with a regexp :

data have;
    string='If  IsEqualTo Inclusion 1 then... set datapoint value for ILIST in Inclusion Criteria to LIST #1 - The subject is a boy or girl, aged ≥7 and <12years (patients who turn 12 years during the study will be allowed to continue in the game)., and execute the ""Return True"" custom function';
    extract=prxchange("s/.*-(.*)\..*/$1/",1,string);
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

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
  • 3 replies
  • 1673 views
  • 1 like
  • 4 in conversation