The answer is simple. When a data step compiles SAS sets up a program
data vector (PDV). There is only one PDV for the data step, no matter how
many datasets are being read or written. All the variables in the incoming
dataset(s) and any variables created in the data step are in the PDV.
Unless you specify otherwise, with KEEP or DROP, when datasets are written
out, all the variables in the PDV are written to all output datasets.
To get what you expected, add a DROP option to your two datasets:
data a(drop=z) b(drop=y);
WA State Caseload Forecast Council
(360) 902-0086 voice
(360) 902-0084 fax
From: Mo Uddin-M [mailto:uddin.m@PG.COM]
Sent: Thursday, March 02, 2000 11:17 AM
Subject: Fundamental Question
I have a very fundamental question. If I run the following code:
do i=1 to 10;
data a b;
if i in (2, 4, 6) then do;
else if i in (9, 10) then do;
proc print data=a;
proc print data=b;
I get these two sets for data a & b;
OBS I X Y Z
1 2 0.00887 0.00887 .
2 4 0.93986 0.93986 .
3 6 0.92773 0.92773 .
OBS I X Y Z
1 9 0.97940 . 0.97940
2 10 0.65666 . 0.65666
My question is why variable Z in data a and Y in data b.
I would appreciate an explanation for this.
Thanks in advance.