turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- IF condition

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-02-2016 08:51 AM

Hello,

I have a data of 4300 lines which now I want to take only part of data for regression.

I have a continouse variables which called FOWNFF, FOWNFNF, DG while nf is 0,1 variable

I want that my population will be: FOWNFF>0.2 and FOWNFNF>0.2 and if nf=1 than take the variable while it is DG>0.2

where fownff>**0.2** and fownfnf>**0.2** if nf=**1** and dg>**0.2**;

that is what I wrote and got an error. The log is:

ERROR: Syntax error while parsing WHERE clause.

ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &, *, **, +, -, /, <, <=, <>, =, >, >=, AND, EQ, GE, GT,

LE, LT, NE, NOT, OR, ^, ^=, |, ||, ~, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

Any help will be acceptable

Thanks

Accepted Solutions

Solution

08-03-2016
01:42 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to yael

08-02-2016 09:07 AM

The statement must either be a where (which means a where condition that is applied directly on the input data before the data step iteration begins) or an if (subsetting if, is processed at the place it is written in the data step).

Within both, you need to define a condition that yields a boolean value (in SAS, this means a numeric value; 0 is false, any non-zero value - usually 1 - is true).

So, if is not allowed within the where condition. You need to build your condition using and, or and not as logical (boolean) operators.

```
where
nf = 0 and fownff > 0.2 and fownfnf > 0.2
or
nf = 1 and dg > 0.2
;
```

Note that logical and takes precedence over logical or in the evaluation, so no parentheses are needed.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers

All Replies

Solution

08-03-2016
01:42 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to yael

08-02-2016 09:07 AM

The statement must either be a where (which means a where condition that is applied directly on the input data before the data step iteration begins) or an if (subsetting if, is processed at the place it is written in the data step).

Within both, you need to define a condition that yields a boolean value (in SAS, this means a numeric value; 0 is false, any non-zero value - usually 1 - is true).

So, if is not allowed within the where condition. You need to build your condition using and, or and not as logical (boolean) operators.

```
where
nf = 0 and fownff > 0.2 and fownfnf > 0.2
or
nf = 1 and dg > 0.2
;
```

Note that logical and takes precedence over logical or in the evaluation, so no parentheses are needed.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers