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 (September 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 27 Sep 2010 17:32:17 -0400
Reply-To:     Nat Wooding <nathani@VERIZON.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <nathani@VERIZON.NET>
Subject:      Re: by group processing, sas certification book, 2nd ed
In-Reply-To:  <883E11039DC948DCB9E86C1B74BC46A2@D1871RB1>
Content-Type: text/plain; charset="us-ascii"

Some folks may have received a usable table but my copy of my email was trash.

Max

If you are still trying to figure this out, look in the documentation for BASE SAS Concepts and under "By Group Processing", look for the topic

How SAS Determines FIRST.VARIABLE and LAST.VARIABLE

There you will find a table that shows the values of the various first. And last. Entries for a multivariable by statement.

Nat Wooding

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Nat Wooding Sent: Monday, September 27, 2010 5:24 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: by group processing, sas certification book, 2nd ed

I have not followed this thread closely but the following table from the Concepts section of the documentation may help. I inserted the table as HTML and I hope that it will be legible to all.

Nat Wooding

Grouping Observations by State, City, Zip Code, and Street

This example shows how SAS uses the FIRST.variable and LAST.variable to flag the beginning and end of four BY groups: State, City, ZipCode, and Street. Six temporary variables are created within the program data vector. These variables can be used during the DATA step, but they do not become variables in the new data set.

In the figure that follows, observations in the SAS data set are arranged in an order that can be used with this BY statement:

by State City ZipCode;

SAS creates the following temporary variables: FIRST.State, LAST.State, FIRST.City, LAST.City, FIRST.ZipCode, and LAST.ZipCode.

Observations in Four BY Groups

Corresponding FIRST. and LAST. Values

State

City

ZipCode

Street

FIRST. State

LAST. State

FIRST. City

LAST. City

FIRST. ZipCode

LAST. ZipCode

AZ

Tucson

85730

Glen Pl

1

1

1

1

1

1

FL

Miami

33133

Rice St

1

0

1

0

1

0

FL

Miami

33133

Tom Ave

0

0

0

0

0

0

FL

Miami

33133

Surrey Dr

0

0

0

0

0

1

FL

Miami

33146

Nervia St

0

0

0

0

1

0

FL

Miami

33146

Corsica St

0

1

0

1

0

1

OH

Miami

45056

Myrtle St

1

1

1

1

1

1

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Schwarz, Barry A Sent: Monday, September 27, 2010 3:20 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: by group processing, sas certification book, 2nd ed

The number of variables in an observation has no affect on the first. and last. variables. Did you mean three or more observations?

Consider a data set with one character variable named x

obs x

1 a

2 b

3 b

4 c

5 c

6 c

Processing this data set with SET and BY x will result in

obs first.x last.x

1 1 1

2 1 0

3 0 1

4 1 0

5 0 0

6 0 1

If this doesn't address the area of your confusion or if you think the results should be different, your question needs to be more specific.

-----Original Message-----

From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of bbser2009

Sent: Saturday, September 25, 2010 12:17 AM

To: SAS-L@LISTSERV.UGA.EDU

Subject: by group processing, sas certification book, 2nd ed

Hi there,

I have read the portion about by group processing in Chapter 12 several

times, still feel confused about those examples presented (I even think they

make mistakes), about the first.variable and last.variable in the situation

where we have 3 or more by variables.

Anyone, by any chance, has read that book? Is there better source explaining

by group processing, first and last.variables?


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