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 (December 1997, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 16 Dec 1997 16:40:49 -0500
Reply-To:     Victor Kamensky <kamensky@AECOM.YU.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Victor Kamensky <kamensky@AECOM.YU.EDU>
Subject:      Re: Strange results
Content-Type: text/plain; charset="us-ascii"

Thanks to Tim Berryhill-the problem is solved. The following data step should be added: data d1 ; set d1; if qnum05=9 then quarter=4;

For the second run results were correct,but it was due to the data: all the records at the end of the nonsorted data set have qnum05=9.

Victor Kamensky

At 04:02 PM 12/15/97 PST, you wrote: >Victor, I notice that there are no variables in common between D1 and D2, and >that they are concatenated (first all observations of D1 are processed, then all >observations of D2). In this case, SAS creates the program data vector for D1 >and D3 with all variables from each dataset (the log shows four variables). >Before processing ANY data, all four variables are missing. Once the first >observation from D1 is read, ID and QNUM05 have values. Get ready: > >!! QUARTER does not have a value until either 1) you read the first observation >from D2 or 2) an observation from D1 has a QNUM05 of 9. Once some D1 >observation with a QNUM05 value of 9 sets QUARTER to 4, QUARTER remains 4 until >an observation from D2 changes that value. > >To test this notion, you might insert a few put statements into the final data >step (both before and after the SET statement). I think you will find the >results were never correct. > >Tim Berryhill - Contract Programmer and General Wizard >TWB2@PGE.COM or http://www.aartwolf.com/twb.html >Frequently at Pacific Gas & Electric Co., San Francisco >The correlation coefficient between their views and >my postings is slightly less than 0 >----------------------[Reply - Original Message]---------------------- > >Sent by:"Victor Kamensky" <kamensky@AECOM.YU.EDU> > Dear SAS-L-ers! >Please take a look at the following log. >I run the same program twice. >The difference between first and second run is that >proc sort is taken out. >First run gives wrong results,second-correct. >Data base d2 is empty. >(Another way of getting correct results > is to drop QUARTER from d2,although d2 is empty). >It does not make any sense. >Any ideas? >Sincerely >Victor Kamensky >Programmer >Albert Einstein College of Medicine > > >18313 *dtt.sas; >18314 *FIRST RUN-WRONG RESULTS; >18315 PROC DBF DB4=d1 OUT=d1(keep=id qnum05);RUN; > >NOTE: 937 observations written to the output SAS data set. >NOTE: The PROCEDURE DBF used 0.22 seconds. > > >18316 PROC DBF DB4=d2 OUT=d2(keep=acrostic quarter);RUN; > >NOTE: 0 observations written to the output SAS data set. >NOTE: The PROCEDURE DBF used 0.05 seconds. > > >18317 proc sort data=d1; by id; run; > >NOTE: The data set WORK.D1 has 937 observations and 2 variables. >NOTE: The PROCEDURE SORT used 0.11 seconds. > > >18318 data d1 d3; >18319 set d1 d2(keep=acrostic quarter); >18320 if qnum05=9 then quarter=4; >18321 if quarter =4 then output d3; >18322 else output d1; >18323 run; > >NOTE: The data set WORK.D1 has 359 observations and 4 variables. >NOTE: The data set WORK.D3 has 578 observations and 4 variables. >NOTE: The DATA statement used 0.55 seconds. > > >18324 >18325 *SECOND RUN-NO SORTING-CORRECT RESULT; >18326 PROC DBF DB4=d1 OUT=d1(keep=id qnum05);RUN; > >NOTE: 937 observations written to the output SAS data set. >NOTE: The PROCEDURE DBF used 0.16 seconds. > > >18327 PROC DBF DB4=d2 OUT=d2(keep=acrostic quarter);RUN; > >NOTE: 0 observations written to the output SAS data set. >NOTE: The PROCEDURE DBF used 0.05 seconds. > > >18328 *proc sort data=d1; *by id; run; >18329 data d1 d3; >18330 set d1 d2(keep=acrostic quarter); >18331 if qnum05=9 then quarter=4; >18332 if quarter =4 then output d3; >18333 else output d1; >18334 run; > >NOTE: The data set WORK.D1 has 704 observations and 4 variables. >NOTE: The data set WORK.D3 has 233 observations and 4 variables. >NOTE: The DATA statement used 0.44 seconds. > >===================================================================== > >


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