Help using Base SAS procedures

DELETE or SELECT TEXT BEGINNING WITH SAME CHARACTER

Reply
Occasional Contributor
Posts: 16

DELETE or SELECT TEXT BEGINNING WITH SAME CHARACTER

I will like to select disease with codes beginning with B2 or C2. Is it possible to use logical operations here. I tried the following, but it did not work

data new;
set lib.data;
where disease like 'B2%' or where disease like 'C2%';
run;

I want to select patients with disease codes B2*** or C2***. Can anyone help.
Super Contributor
Posts: 439

Re: DELETE or SELECT TEXT BEGINNING WITH SAME CHARACTER

Posted in reply to Statsconsultancy
This should work, you just have the syntax not entirely correct. Ommit the repetition of WHERE:

where disease like 'B2%' or disease like 'C2%';

That should do it. Basic SQL, nothing SAS here.

Good luck, Jan.
PROC Star
Posts: 7,471

Re: DELETE or SELECT TEXT BEGINNING WITH SAME CHARACTER

Posted in reply to jklaverstijn
Works in data step. Nothing SQL here!

Is it Friday yet?
Art
Frequent Contributor
Posts: 91

Re: DELETE or SELECT TEXT BEGINNING WITH SAME CHARACTER

You could also do:

data new;
set lib.data;
where disease IN: ('B2','C2'); /* note the colon on the IN, just matches on 1st chars*/
run;
Ask a Question
Discussion stats
  • 3 replies
  • 127 views
  • 0 likes
  • 4 in conversation