LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2001, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Mar 2001 15:35:18 -0000
Reply-To:     DavidJohnson@HALIFAX.CO.UK
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         David Johnson <DavidJohnson@HALIFAX.CO.UK>
Subject:      LocateN() with Where(), V6.12 TS065 Windows
Content-Type: text/plain; charset=us-ascii

I tracked this through SAS yesterday and their response was that this is a bug, fixed in V8. Has anyone else encountered it and proven a solution?

. Open a data set . Apply a where clause . Locate a value . Use the observation number in a fetch.

Here is some test code, the data set (19 obs) is part of the SAS/Assist generated data sets.

H = 66.5; DsId = Open( 'SASUSER.CLASS'); RCWhere = Where( DsId, 'SEX="M"'); NObsNum = LocateN( DsId, VarNum( DsId, 'HEIGHT'), H); Put 'Test observation number found ' NObsNum =; NFetch = FetchObs( DsId, NObsNum); DsId = Close( DsId);

Test first with an H value of 99. The NObsNum is 0, which is correct.

Test now for 66.5 and the Where clause commented out. The NObsNum is 6 for the first (female) observation. That is correct.

Now apply the where clause for 'sex=M' and the NObsNum should be 10. It is 19!

The documentation for LocateN states that the number returned is not the observation number, because deleted observations, and observations excluded by a where clause are not counted.

Consequently, the value returned should be the same as FetchObs() expects, since this honours the where clause. However, with the where clause applied, Fetchobs is passed the absolute observation number and fails with return code -1 which indicates a search past end of data set.

We have two solutions, one of which we are using at present. I am more concerned with the consistency of the problem, and need to know if anyone else has seen this issue and found it to be intermittent. I am also interested in other solutions.

The primary solution we have documented is: . Release the where clause after the LocateN so FetchObs() functions on the absolute obs number. The danger with this approach is that if the where() clause is SOMETIMES honoured, you'll retrieve the wrong observation number.

Comments appreciated, please post direct. I will summarise to the list all direct postings and the final solution.

Thanks

David

** ##*

David Johnson > Group Technology & Systems - Mortgages Business Information Systems Consultant Collinsons 2nd Floor Direct Dial : (01422) 39 1360 Ext. : 31360 This message is attributable to the sender and does not necessarily reflect the view of Halifax Group plc or its subsidiaries.

------------------------------------------------------------------------------ Part of the Halifax Group, Halifax plc, Registered in England No. 2367076. Registered Office: Trinity Road, Halifax, West Yorkshire HX1 2RG. Represents only the Halifax Financial Services Marketing Group for the purposes of advising on and selling life assurance, pensions and unit trust business. The Marketing Group is regulated by the Personal Investment Authority. Switchboard 01422 333333.

=============================================================================


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