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 (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 5 Oct 2009 14:42:28 -0400
Reply-To:     Andrew.Clapson@STATCAN.GC.CA
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Andrew Clapson <Andrew.Clapson@STATCAN.GC.CA>
Subject:      Assigning the value of one variable to another
Content-Type: text/plain; charset="US-ASCII"

Hello SAS list,

I am trying to figure out how to take a variable and give it the value (i.e. copy the value) of another observation in the dataset.

Here's the skinny:

I have an identifier variable ('ID'), a status code ('Status'), and date of birth ('Date'), let's say. I want each observation to have a value for 'Date', but some are missing. Of the observations missing a value for the 'Date' variable, those with the 'Status' of "03" should have the same date of birth - 'Date' - as another observation in the dataset. (These data aren't people, they're companies, and some companies are 'children' of others, so I can copy the 'Date' value from the parent company).

I got about as far as this with the code:

DATA DS2; SET DS1; IF 'Status' = 03 THEN DO; IF 'ID' IN (#1,#2,#2) THEN 'Date' = ('Date' value from observation w/ ID #4) ??? END; RUN;

What I want to do is: - for all observations with a 'Status' of "03", make the value of the 'Date' variable equal to that of its parent company. I have a list of the 'ID' numbers, so it is simple to tell which parents correspond to which children, but what procedure would I use?

Is there a command and/or an elegant way to assign values to specific observations like this?

Thanks for your help,

Andy Clapson

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