Date: Mon, 18 Oct 2004 16:44:30 -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 with Most recent date
DO loops are the usual tool for referencing and processing information in
arrays.
The fact that the present task is posing difficulties may be an indication
that the data structure is clumsy. I would think about a more normalized
(think long and narrow) structure.
On Mon, 18 Oct 2004 13:31:32 -0400, Rob <sasuser00@HOTMAIL.COM> wrote:
>The problem is that there is an array for date of data. For one record
>there is an APE start date and date_of_data1 to date_of_data100. I have
>to read each one of these and determine which one is the closest one prior
>to the ape start date. Can I add an array to this code?
>
>The other thing is that I have variables sweek1 to sweek100 and this
>computes the time between the two dates. Can I somehow just read through
>these variables and retain the lowest value, then I could get the family
>status associated with the record and plug it into the control variable.
>
>I would like to do something like the following:
>
>if sweek2 GT sweek 1 /* keep the value of sweek 2 */
> then c_family_status = family_status
>else if sweek3 gt sweek2
> then c_family_Status = family_status
>else if sweek4 gt sweek 3
>etc.
>
>Any suggestions?
>
>On Mon, 18 Oct 2004 08:42:41 -0700, Dennis Diskin <diskin@SNET.NET> wrote:
>
>>A pretty standard problem with various solutions.
>>One is to split out a file with the last prior records and then merge it
>back in:
>>Here's some untested code, assuming yourdata already sorted on sin and
>ape_date as in your sample:
>>
>>data base (keep=sin base_status);
>>set yourdata(where=(ape_date LT data_date rename=status=base_status));
>>by sin descending ape_date;
>>if first.id;
>>run;
>>
>>data new;
>>merge yourdata base;
>>by sin;
>>run;
>>
>>HTH,
>>Dennis Diskin
>>
>>Rob <sasuser00@HOTMAIL.COM> wrote:
>>Hi,
>>
>>I am wondering how to do the following:
>>
>>I am creating some control variables, one is called c_family_status which
>>is going to be the status of the most recent record prior to the start
>>date.
>>
>>So for example, I have an APE start date for 5 observations for SIN
>>MT0000035. I also have another date (date_of_data) which is in an array
>>for the same SIN in the same observation. I have to make sure I get the
>>observation with the most recent APE date and which has a date_of_data
>>prior to that start date.
>>
>>For example:
>>
>>MT35
>>
>>APE date of family weeks prior
>>date data status to ape date
>>
>>13608 13758 11 22
>>13660 13758 11 14
>>13782 13758 12 -3
>>13847 13758 11 -12
>>14979 13209 11 -174
>>
>>So I would like to see 3 go in to the control variable family status since
>>it is the closest date prior to the APE date.
>>
>>Any help would be appreciated!
>>
>>Thanks!
|