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
- /
- Base SAS Programming
- /
- Where and PDV

- 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

01-14-2011 03:41 AM

data A;

do i=1 to 10;

output;

end;

run;

data B;

set A(where=(i<8)) A;

where i>3;

run;

SAS help document says "A WHERE expression tests the condition before an observation is read into the PDV". But there are 14 observations in B. What happens in PDV?

do i=1 to 10;

output;

end;

run;

data B;

set A(where=(i<8)) A;

where i>3;

run;

SAS help document says "A WHERE expression tests the condition before an observation is read into the PDV". But there are 14 observations in B. What happens in PDV?

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

Posted in reply to deleted_user

01-14-2011 04:23 AM

Add dataset option IN= to your SET statement and enlighten us all. Somewhat like

[pre]

data b;

set a(in=a1 where=(i<8)) a(in=a2);

where i>3;

put (_n_ i a1 a2) (=);

run;

[/pre]

[pre]

data b;

set a(in=a1 where=(i<8)) a(in=a2);

where i>3;

put (_n_ i a1 a2) (=);

run;

[/pre]

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

Posted in reply to Robert_Bardos

01-14-2011 09:25 AM

Consider the possibilities:

- Learning opportunity....

- Self-discovery...

- Desk-checking SAS program code-path / logic...

Amazing how much information one can learn from a PUT (to the SAS log) or with a PUTLOG statement.

Scott Barry

SBBWorks, Inc.

- Learning opportunity....

- Self-discovery...

- Desk-checking SAS program code-path / logic...

Amazing how much information one can learn from a PUT (to the SAS log) or with a PUTLOG statement.

Scott Barry

SBBWorks, Inc.

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

Posted in reply to deleted_user

01-14-2011 09:45 AM

clearly when you use a where clause in data set options, it doesn't use the conditions of the where statement . This causes a WARNING if A is read on the SET statement only with WHERE clauses[pre]25 data B;

26 set A(where=(i<8)) ;

27 where i>3;

WARNING: The WHERE statement cannot be applied to a data set on

the last SET/MERGE/UPDATE/MODIFY statement. Either

the data sets listed failed with open errors or they

already specify a WHERE data set option.

28 run;

NOTE: There were 7 observations read from the data set WORK.A.

WHERE i<8;

NOTE: The data set WORK.B has 7 [/pre] This is tested on SAS9.2

It may be different on your release.

26 set A(where=(i<8)) ;

27 where i>3;

WARNING: The WHERE statement cannot be applied to a data set on

the last SET/MERGE/UPDATE/MODIFY statement. Either

the data sets listed failed with open errors or they

already specify a WHERE data set option.

28 run;

NOTE: There were 7 observations read from the data set WORK.A.

WHERE i<8;

NOTE: The data set WORK.B has 7 [/pre] This is tested on SAS9.2

It may be different on your release.

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

Posted in reply to deleted_user

01-14-2011 09:48 AM

...

> SAS help document says "A WHERE expression tests the

> condition before an observation is read into the

> PDV".

...

It is*also* clearly documented here that:

"If you use both the WHERE= data set option and the WHERE statement in the same DATA step, SAS ignores the WHERE statement for data sets with the WHERE= data set option."

> SAS help document says "A WHERE expression tests the

> condition before an observation is read into the

> PDV".

...

It is

"If you use both the WHERE= data set option and the WHERE statement in the same DATA step, SAS ignores the WHERE statement for data sets with the WHERE= data set option."

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

Posted in reply to deleted_user

01-15-2011 02:26 AM

"If you use both the WHERE= data set option and the WHERE statement in the same DATA step, SAS ignores the WHERE statement for data sets with the WHERE= data set option."

I get it. Thank you all.

I get it. Thank you all.