LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 2 Mar 2000 11:18:12 -0800
Reply-To:   "Lund, Pete" <Peter.Lund@CFC.WA.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Lund, Pete" <Peter.Lund@CFC.WA.GOV>
Subject:   Re: Fundamental Question
Comments:   To: Mo Uddin-M <uddin.m@PG.COM>
Content-Type:   text/plain; charset="windows-1252"

Mohammad - 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);

Pete Lund WA State Caseload Forecast Council (360) 902-0086 voice (360) 902-0084 fax peter.lund@cfc.wa.gov

-----Original Message----- From: Mo Uddin-M [mailto:uddin.m@PG.COM] Sent: Thursday, March 02, 2000 11:17 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Fundamental Question

Hi Folks,

I have a very fundamental question. If I run the following code:

data k; do i=1 to 10; x=ranuni(100); output; end;

data a b; set k; if i in (2, 4, 6) then do; y=x; output a; end; else if i in (9, 10) then do; z=x; output b; end; proc print data=a; proc print data=b; run;

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.

Mohammad


Back to: Top of message | Previous page | Main SAS-L page