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 (November 2001, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 30 Nov 2001 10:43:40 -0000
Reply-To:     Nigel.Pain@SCOTLAND.GSI.GOV.UK
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nigel Pain <Nigel.Pain@SCOTLAND.GSI.GOV.UK>
Subject:      Re: First.Variable Question - Resolved
Comments: To: CWard@ACCORDANT.NET
Content-Type: multipart/alternative;

***************************************************************************** This email and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. *****************************************************************************

A few comments on your code and an attempt to explain why the resolution worked.

First, as a point of style, I always recommend that the BY statement immediately follows the SET (or MERGE or UPDATE) statement. Syntactically it doesn't matter because SAS deals with it at compilation, not execution, but it makes the program clearer to us poor mortals. Likewise, I put most of the other compilation-time statements (eg. *RETAIN*, LENGTH, FORMAT, INFORMAT, ATTRIB, ARRAY, KEEP, DROP) immediately after the DATA statement unless there is a good reason not to (can't think of any off-hand). It makes the program easier for humans to interpret and can have the benefit of not overwriting data if you accidentally leave the semicolon off the DATA statement (write the simplest step possible and work out what happens if you do omit that semicolon - hint: look for a dataset called WORK.SET!).

Second, the NOTSORTED option is unnecessary because you have sorted the BY variables.

Third, on you subsetting IF statement, none of the parentheses are strictly necessary as the only logical operator is AND. Once again, style only for easy reading.

Fourth, the "payer in: ('Plan A')" condition is redundant in your second step because you have already subsetted on that in the first step.

Last, when you combine all those conditions in a single IF statement using the AND logical operator, then they all have to be true. Let's take a simplified situation where you want IP=1 and first.DateOfService, and data as follows:

IP DateOfService 1 1/1/01 2 1/1/01 3 1/1/01 2 2/1/01 1 2/1/01 1 2/1/01

In your original program, the first record would be selected (IP=1 and first.DateOfService=1) and the second and third, correctly, would not (on both counts). Now look at the fourth to sixth records. The fourth would not be selected because IP=2 (even though first.DateOfService=1). However, the fifth and sixth would also not be selected because, although IP=1, first.DateOfService=0. When you use the corrected program, subsetting by IP in the first step and by first.DateOfService in the second, after the first step you have the following:

IP DateOfService 1 1/1/01 1 2/1/01 1 2/1/01

In the second step, the first two of these records fulfils the first.DateOfService condition. BINGO!!

I hope this is helpful.

*************************************************** Nigel Pain Scottish Executive Development Department Business Support Unit Victoria Quay EDINBURGH EH6 6QQ UK Tel +44 131 244 7237 Fax +44 7092 014235

Mailto:nigel.pain@scotland.gsi.gov.uk Website: http:\\www.scotland.gov.uk

> -----Original Message----- > From: Catherine Ward [mailto:CWard@ACCORDANT.NET] > Sent: 29 November 2001 17:48 > Subject: Re: First.Variable Question - Resolved > > > I still don't understand why the problem occurred, but the > resolution was to > break it into two distinct steps. I'd like to thank all who offered > suggestions. The dialogue helped me to step back and > realize I didn't need > to do this all in one step. The code (again, less the myriad > of fields > defining my inclusion criteria) is below. > > Thanks again! > > Catherine Ward, RN, MSN/MBA > Medical Economics Analyst > Accordant Health Services > cward@accordant.net > (336) 315-3757 > Visit our patient communities at http://www.accordant.com or > our corporate > site at http://www.accordant.net > > -------------------------------------------------------------- > -------------- > -------------------------------------------------------------- > -------------- > -------------- > proc sort data = &OTLIB..StudyClaims; > by payer MemberID DateOfService; > run; > > data &OTLIB..preadmits ( keep = DateOfService ServCatI > ServCatII ServCatIII > MemberID payer disease admits IP); > set &OTLIB..StudyClaims; > if payer in: ('Plan A') then do; > IP = ( ...< criteria from other fields inserted here> ...); > by payer MemberID DateOfService; > retain admits 1; > if ( IP = 1 and ( ServCatI =: '007'and ServCatII ^=:'011')); > output &OTLIB..admits; > end; > run; > > data &OTLIB..admits ; > set &OTLIB..preadmits; > if payer in: ('Plan A') and first.DateOfService; > run; > -------------------------------------------------------------- > -------------- > -------------------------------------------------------------- > -------------- > -------------- >


[text/html]


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