Quartz | Level 8

## IF condition

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

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: IF condition

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.

Super User

## Re: IF condition

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.

Discussion stats