Desktop productivity for business analysts and programmers

double WHERE statement

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

double WHERE statement

Would you be able to tell me how to fix my double WHERE statement so it works?

 

proc reg data=datananame (where=(Month in (1,2,3)) and (Day in (1,2,3,4,5)));
model Y=X;
run;


Accepted Solutions
Solution
‎07-02-2018 11:42 AM
Super User
Super User
Posts: 8,279

Re: double WHERE statement


@matt23 wrote:

Would you be able to tell me how to fix my double WHERE statement so it works?

 

proc reg data=datananame (where=(Month in (1,2,3)) and (Day in (1,2,3,4,5)));
model Y=X;
run;


You just need to get the parenthesis nested properly.

You could also look at using the WHERE statement instead of the WHERE= dataset option. 

That way you can a WHERE ALSO statement to add additional restrictions.

proc reg data=datananame;
  where Month in (1,2,3);
  where also Day in (1,2,3,4,5);
  model Y=X;
run;

View solution in original post


All Replies
Super User
Posts: 10,571

Re: double WHERE statement

where=(Month in (1,2,3) and Day in (1,2,3,4,5))

just too many parentheses.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎07-02-2018 11:42 AM
Super User
Super User
Posts: 8,279

Re: double WHERE statement


@matt23 wrote:

Would you be able to tell me how to fix my double WHERE statement so it works?

 

proc reg data=datananame (where=(Month in (1,2,3)) and (Day in (1,2,3,4,5)));
model Y=X;
run;


You just need to get the parenthesis nested properly.

You could also look at using the WHERE statement instead of the WHERE= dataset option. 

That way you can a WHERE ALSO statement to add additional restrictions.

proc reg data=datananame;
  where Month in (1,2,3);
  where also Day in (1,2,3,4,5);
  model Y=X;
run;
☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 117 views
  • 1 like
  • 3 in conversation