BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
5 REPLIES 5
Robert_Bardos
Fluorite | Level 6
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]
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
Peter_C
Rhodochrosite | Level 12
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.
chang_y_chung_hotmail_com
Obsidian | Level 7
...

> 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."
deleted_user
Not applicable
"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.
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2955 views
  • 0 likes
  • 5 in conversation