Date: Mon, 14 Jul 2008 18:17:35 -0400
Reply-To: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject: Re: Simultaneously using variables from a dataset that is being
Content-Type: text/plain; charset="us-ascii"
Before you commit to this plan, you may wish to consider the alternative
favored by database programmers: normalizing your data into two
datasets, persons and events, and use a personID in the events dataset
to relate events back to persons. For many reasons it makes sense to
keep separate dimensions of data in separate relations (datasets).
It often dawns on programmers later in the process that the number of
events per person tends to increase and each increase past a maximum
numbers forces restructuring of a dataset. Search the Web on "relational
database design" for more information.
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Monday, July 14, 2008 5:40 PM
Subject: Simultaneously using variables from a dataset that is being
I have a number of datasets in which each record belong to a person. The
first portion of the record is the person's info and the second part is
a sequence of events (date of the event, code and some
details) for the person. But unfortunately, there are some records where
in one record there is a person's info and a certain event (date, etc.)
and there is another record for the same person (info in the initial
part) and then details about another event.
What I want to do is prepare a dataset which has a unique record for a
person. The records contains the personal info and all the sequence of
events in the same record. Something like ID, DOB, ..., EVENT1, DATE1,
CODE1, EVENT2, DATE2, CODE2, and so on.
The number of events per person is not known but I can assume an upper
limit on the number of columns (so the dataset can have some blank
fields). So, I created a blank dataset using the DATA step and giving
the format of the intended dataset. Now I want to add records to this
dataset (A) from dataset B with "non-unique" records. I want to :
*check the ID in dataset A with that in B
if ID doesn't exist in A then add record from B to A
else (if ID exists)
DO i = 1 to <upperlimit>
if the fields EVENT(i) are blank
add event data;
So here, I'm not sure how I can simultaneously use the variables from
the dataset I am creating. Can somebody, please, suggest how this can be
done ? Or if there is another / better procedure ?
Thanks a bunch in advance