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 (January 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 13 Jan 2000 19:11:44 +0100
Reply-To:     "Christian F.G. Schendera" <schendera@NIKOCITY.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Christian F.G. Schendera" <schendera@NIKOCITY.DE>
Subject:      Q: lag function
Comments: To: SASL <SAS-L@UGA.CC.UGA.EDU>
Content-Type: text/plain; charset="iso-8859-1"

I have the following lag function code..........

data PCTVLF2 ; set PCTVLF1 ; by YEARPAIR BIRDTYPE METHOD ; a=lag(PCTDIFF) ; if first.METHOD then PCTDEV=100 ; else PCTDEV =(PCTDIFF/a*100)-100 ; put PCTDEV = ; run ;

.........and want to have the output look like this:

BIRDTYPE METHOD YEARPAIRs 92/93 93/94............. 94/95 Blackbird L 130.303 (PCTDIFF +30.303 to start value 100%) xyz (130.303+/-PCTDIFF) abc (xyz+/-PCTDIFF)............. Blackbird P ................ Finch L 64.865 (100%-PCTDIFF 35.135) xyz (130.303+/-PCTDIFF) Finch P...... My general aim is to have an annual data development expressed in percentages. The first yearpair is related to 100% to get some standardized beginning. Then all other differences are percentage calculated from the obtained results. My LAG code is very close to this output but there seems to be a little flaw about the starting value. I cannot get it started with the right YEARPAIR. Help appreciated, Chris

*******************example PCTVLF1 dataset structure*****************

note: Dataset contains two data rows per BIRDTYPE and YEARPAIR: Methods L and P. Yearpair range from 92/93 (for some birdtypes later) to yearpair 97/98. QJ1 and QJ2 are percentage values for years1 and 2. PDIFF stands for the difference between QJ1 and QJ2 as asolute amount. PCTDIFF expresses this absolute amount difference as percentage quotient related to QJ1. OBS YEARPAIR YEAR1 YEAR2 BIRDTYPE METHOD QJ1 QJ2 PDIFF PCTDIFF

1 92/93 1992 1993 Blackbird L 16.5 21.5 5.0 30.303 2 92/93 1992 1993 Finch L 18.5 12.0 -6.5 -35.135 3 92/93 1992 1993 Eagle L 0.5 1.5 1.0 200.000 4 92/93 1992 1993 Eagle L 4.5 5.5 1.0 22.222 5 92/93 1992 1993 Crow L 18.5 28.5 10.0 54.054 6 92/93 1992 1993 Chicken L 1.5 0.5 -1.0 -66.667 7 92/93 1992 1993 Whale ;-) L 1.0 1.0 0.0 0.000 8 92/93 1992 1993 Sparrow L 0.5 0.5 0.0 0.000...................


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