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 (July 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 18 Jul 2003 16:15:10 -0400
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: help

1. In the future, please use more informative Subject lines. Something like "RETAIN Problem" or "Filling In Missing Values" would have been appropriate here.

2. I don't think the code you present is really what you ran, because it fails due to the BY variables being out of sequence before it processes the observation with LNUM=9943.

3. Try this (my additions in UPPER CASE):

data d2; set d1; by id lnum NOTSORTED; retain clm2; LENGTH CLM2 $ 8.; IF FIRST.LNUM THEN CLM2 = ''; if clm ne ' ' then do; clm2=clm; end; run;

4. You do not indicate whether CLM might take on different values within a BY group. Your example suggests not. My code should work in either case, but a solution which assigns values to CLM2 only at BY group boundaries would not.

On Fri, 18 Jul 2003 11:28:25 -0700, Max <max8ca@YAHOO.COM> wrote:

>Hello there, > >I have a dataset where one variable have some missing >value. >I want to replace the missing value with the value >above >it under the same LNUM. The original data is > > > ID LNUM clm > > 483 9048 J085 > 483 9943 > 483 2652 H915 > 483 2652 > > >I need to create a new variable that takes the same >value for >CLM under the same LNUM, so the new variable looks >like: > > > ID LNUM clm clm2 > > 483 9048 J085 J085 > 483 9943 > 483 2652 H915 H915 > 483 2652 H915 > > >I tried to use RETAIN, but it assigns the value for >LNUM 9943, >which is not supposed to: > > ID LNUM clm clm2 > > 483 9048 J085 J085 > 483 9943 JO85 > 483 2652 H915 H915 > 483 2652 H915 > > >My code is > > >data d2; > set d1; > by id lnum; > retain clm2; > if clm ne ' ' then do; > clm2=clm; > end; >run; > > > >Any help would be appreciated. > > >Max > >__________________________________ >Do you Yahoo!? >SBC Yahoo! DSL - Now only $29.95 per month! >http://sbc.yahoo.com


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