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.
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;
And for "Lots of text" if defined as "more than 30 characters":
data want2; set have; where length(Description) > 30; run;
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"?
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!
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.
Ready to level-up your skills? Choose your own adventure.