Turn on suggestions

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

Showing results for

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

Options

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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 08-02-2016 08:51 AM
(767 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

1 REPLY 1

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer.

** **

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.