Home > Net >  Deleting rows when meeting a specific condition when in a range in SAS
Deleting rows when meeting a specific condition when in a range in SAS

Time:11-12

I need help with the following dataset:

ID   Code  SAStime
001  1     0
001  1     600
001  1     1200
...  ...   ...
001  1     84600
001  2     85200
001  2     85800

I would like to be able to tell the program, that if Code=1 between SAStime 0 and 85800 then to delete those row of data. So I have something left, like this:

ID   Code  SAStime
001  2     85200
001  2     85800

I've tried with drop, keep and where functions but for some reason it's not working.

CodePudding user response:

I think you are asking about SAS grammar, you can learn it from .
As for this question, the anwser is below:

data have;
    input ID$ Code SAStime;
    cards;
001  1     0
001  1     600
001  1     1200
001  1     84600
001  2     85200
001  2     85800
;
run;

data want;
    set have;
    if Code = 1 and 0 <= SAStime <= 85800 then delete;
run;
  • Related