Need help with the drop/delete statement

Reply
New Contributor
Posts: 2

Need help with the drop/delete statement

Hi. First off thank you so much if you reply. I tested a procedure 4 times, so I have 4 trials (Trial1...Trial4) at 7 frequencies (125, 250, 500, 1000, 2000, 4000, 8000 Hz). There is no data for Trial4 at 125 Hz and therefore, I would like to drop those observation so that they are not counted in my results. I am unable to use drop to do this.  I am posting some of the code that I have been using.

data one;

  set local.dataname;

  if trial = "A" then trial = 4;

  Trial1 = (Trial =1);

  Trial2 = (Trial =2);

  Trial3 = (Trial =3);

  Trial4 = (Trial =4);

Freq1 = (Frequency =125);

  Freq2 = (Frequency =250);

  Freq3 = (Frequency =500);

  Freq4 = (Frequency =1000);

  Freq5 = (Frequency =2000);

  Freq6 = (Frequency =4000);

  Freq7 = (Frequency =8000);

run;

data room1;

  set one;

  if room = "1" or trial = 4;

run;

data room2;

  set one;

  if room = "2" or trial = 4;

run;

proc sort data =room1;

  by User Var2;

run;

Super User
Posts: 5,082

Re: Need help with the drop/delete statement

True, you can't use DROP to get rid of observations (rows).  DROP gets rid of variables (columns).  But you could add this statement to your first DATA step:

if trial=4 and frequency=125 then delete;

That should do what you have asked.

Ask a Question
Discussion stats
  • 1 reply
  • 227 views
  • 0 likes
  • 2 in conversation