## double WHERE statement

Solved
Frequent Contributor
Posts: 89

# 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
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;``````

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
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.