BookmarkSubscribeRSS Feed
marleeakerson
Calcite | Level 5

Hello, 

 

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. 

 

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Like this?

 

data have;
input Description $ 1-66 Count;
datalines;
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');
run;
ballardw
Super User

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

 

data want2;
   set have;
   where length(Description) > 30;
run;
PaigeMiller
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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 494 views
  • 0 likes
  • 4 in conversation