DATA Step, Macro, Functions and more

To select a few conditions

Accepted Solution Solved
Reply
Contributor
Posts: 66
Accepted Solution

To select a few conditions

Hi. 

I wonder how I can choose Phoneme_stress condition of 0 and 1 and drop 2, 3, 4, and 5.

Neither of below codes worked.

Could you please help me following codes?

 

data a1.prediss1;
set a1.prediss;
where Error=0 And [Phoneme_stress=0 or Phonem_stress=1];
run;


data a1.Prediss1;
set a1.Prediss;
if Phonem_stress in (2, 3, 4, 5) then delete;
where error=0;
run;

 

Thank you.


Accepted Solutions
Solution
3 weeks ago
Super User
Posts: 23,771

Re: To select a few conditions

Either of these changes should work:

 

data a1.prediss1;
set a1.prediss;
where Error=0 And (Phoneme_stress in (0, 1));
run;


data a1.Prediss1;
set a1.Prediss;
if Phonem_stress in (2, 3, 4, 5)  and error ne 0 then delete;
run;

 

View solution in original post


All Replies
Solution
3 weeks ago
Super User
Posts: 23,771

Re: To select a few conditions

Either of these changes should work:

 

data a1.prediss1;
set a1.prediss;
where Error=0 And (Phoneme_stress in (0, 1));
run;


data a1.Prediss1;
set a1.Prediss;
if Phonem_stress in (2, 3, 4, 5)  and error ne 0 then delete;
run;

 

Contributor
Posts: 66

Re: To select a few conditions

Thank you.

Super User
Posts: 6,785

Re: To select a few conditions

Your second program might be fine as is ... as long as you are spelling the variable name correctly.  Is it Phoneme_stress, or is it Phonem_stress?

 

Also, you never explained ERROR and what that is about.  So all we can do is assume you have used it correctly.

Contributor
Posts: 66

Re: To select a few conditions

[ Edited ]
Posted in reply to Astounding

I wanted to included only error=0 values in all those conditions I wanted to include (phoneme_stress=0 or 1).

 

Does it change any of the codes I created or received from Reeza?

 

Super User
Posts: 6,785

Re: To select a few conditions

It doesn't change either of @Reeza's programs.  You might want to select one or the  other, based on how you want bad data to be handled.  What should happen of Phoneme_stress is missing, or 8, for example?

Contributor
Posts: 66

Re: To select a few conditions

[ Edited ]
Posted in reply to Astounding

After exploring a little bit, I found following two codes worked.

 


data a1.prediss1;
set a1.prediss;
where Error=0 And (Phoneme_stress in (0, 1));
run;


data a1.Prediss1;
set a1.Prediss;
where error=0;
if Phoneme_stress in (2, 3, 4, 5) then delete;
run;

 

I wanted to include only Error=0. Error is a dichotomous variable.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 108 views
  • 2 likes
  • 3 in conversation