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 (March 2000, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 17 Mar 2000 09:49:11 +0100
Reply-To:   VITE Philippe <Philippe.VITE@GEP.FR>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   VITE Philippe <Philippe.VITE@GEP.FR>
Subject:   lag & retain
Content-Type:   text/plain; charset="iso-8859-1"

Hi everybody,

My pb is the following.

I have n processes in my table, indexed by T (n*T rows).

The state of each process (Raph) is indicated by the variable 'state'.

I want to create a variable movement 'mvt' : each time a raph goes from one value of state to another value of state, i want mvt to be oldstate_newstate.

I tried to do this in a data step using RETAIN and LAG. But it does not work properly.

Here's my programm :

DATA roue.fort; retain raph state; set data; length mvt $12; if state=lag(state) then mvt=0; else if raph=lag(raph) then mvt=compress(lag(state)||"_"||state); run;

The result is that mvt appears to be different from zero at the relevent times, but i get :

mvt=newstate_newstate instead of oldstate_newstate.

It can be done in 2 datasteps, but I would be ashamed to do so...

Any help would be very appreciated.

Philippe.

> Philippe Vité > -------------------------------------------------------------------------- > Paribas - Nouvelles Technologies - Méthodes Statistiques > 5, av Kléber, bureau 584. > 75016 Paris > 01 40 67 40 16 > philippe.vite@gep.fr


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