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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 691 views
  • 0 likes
  • 4 in conversation