BookmarkSubscribeRSS Feed
Calcite | Level 5



I am wondering if it is possible to use the where or if statements to select certain observations that have a lot of text in them. For instance consider the following example table:


Description                                                                                                                Count 

17-Hydroxypregnenolone (Hormone) Level                                                                 11

3d Radiographic Procedure                                                                                          62

3d Radiographic Procedure With Computerized Image Postprocessing                      31

Abdominal Removal Of Uterus Cervix And Lymph Nodes                                            28

Procedure for Abdominal Pain                                                                                      57


And if I only wanted to keep the observations that contained "procedure" somewhere in the title, how would I do that? 


Thank you. 


Tourmaline | Level 20

Like this?


data have;
input Description $ 1-66 Count;
17-Hydroxypregnenolone (Hormone) Level                            11
3d Radiographic Procedure                                         62
3d Radiographic Procedure With Computerized Image Postprocessing  31
Abdominal Removal Of Uterus Cervix And Lymph Nodes                28
Procedure for Abdominal Pain                                      57

data want;
   set have;
   where find(Description, 'procedure', 'i');
Super User

And for "Lots of text" if defined as "more than 30 characters":


data want2;
   set have;
   where length(Description) > 30;
Diamond | Level 26
if find(description,'procedure','i')>0 then output;

Would you please be kind enough to help us out and fix the Subject line of your original post to say "observations" instead of "variables"?

Paige Miller

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!
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
  • 3 replies
  • 4 in conversation