Date: Mon, 9 Oct 2006 21:56:03 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: Help needed to create new variable
1. Why don't you show the results you get from running your code and point
out what makes you "not sure".
2. Is your sample data designed to present all of the possible
circumstances, or is it just an extract from your actual data? It should be
the former.
On Mon, 9 Oct 2006 00:25:14 -0700, vijayakumar <vijayk.kannan@GMAIL.COM> wrote:
>Dear Group members,
>
>I have a specification to create one variable named " emply" as shown
>below with the code but I am not sure about whether my way of creating
>the variable is meeting the exact specification as given in the code .
>So could any please give a correct logic to create the variable
>"emply".
>
>/****************************************************************************************
> variable
specification for "emply"
>A patient is considered employed at Pre-Op if they have a non-missing
>value for empcd
>A patient is considered unemployed at Pre-Op if they have a non-missing
>value for unemcd
>At pre-op, if a patient has non-missing empcd and non-missing unemcd
>(which we see when empcd=3), then label the patient as employed at
>Pre-op.
>AT ANY VISIT, if a patient has a non-missing value for empcd,
>then automatically assign unemcd as missing.
>Here is the logic for the follow-up visits:
> If the jobchgyn is 1 (yes) and empcd is non-missing then the patient
>is
>employed at the present visit
> If the jobchgyn is 1 (yes) and empcd is missing and unemcd is
>non-missing,
>then the patient is unemployed at the present visit
> If the jobchgyn is missing and empcd is non-missing, then the
>patient is
>considered employed at the present visit.
> If the jobchgyn is 0 (No) and empcd is non-missing, then patient is
>considered employed at the present visit.
> If the jobchgyn is 0 (No) and empcd is missing, then use the
>employment
>status at the previous visit as the employment status at the present
>visit.
>*****************************************************************************************/
>dm 'clear out'; dm 'clear log';
>data indpou;
>input subject visitnum $ empcd unemcd jobchgyn;
>cards;
>01001 00 1 . .
>01001 02 1 . 1
>01001 03 . . 0
>01001 12 1 . 1
>01001 18 . . 0
>01001 24 . . 0
>01002 00 2 . .
>01002 02 . . .
>01002 06 . . 0
>01002 24 . 1 1
>01003 00 3 . .
>01003 02 . . 0
>01003 03 . . 0
>01003 06 . . 0
>01003 12 1 . 1
>01003 18 . . 0
>01003 24 3 . 1
>01004 00 1 . .
>01004 02 . . 0
>01004 06 1 . 1
>01004 12 . . 0
>01004 24 1 . 0
>01005 00 1 . .
>01005 02 . . 0
>01005 12 2 . 1
>01005 18 . . 0
>01005 24 1 . 1
>01006 00 1 . .
>01006 02 . . 0
>01006 03 . . 0
>01006 06 . . 0
>01006 12 1 . 0
>01006 18 . . 0
>01006 24 . . 0
>01009 00 1 . .
>01009 03 . . 0
>01009 06 1 . 0
>01009 24 . . 0
>01010 00 3 . .
>01010 02 . . 0
>01010 03 . . 0
>01010 12 1 . 1
>01010 24 2 . 0
>01011 00 1 . .
>01011 02 . . 0
>01011 03 1 . 1
>01011 06 1 . 1
>01011 12 3 . 0
>01011 18 2 . 0
>01011 24 2 . 1
>run;
>data varia;
>set indpou;
>retain v1;
>if empcd ne . then unemcd=.;
>if visitnum='00' then do;
>if empcd ne . then emply=1;
>if unemcd ne . then emply=2;
>if empcd ne . and unemcd ne . and empcd=3 then emply=1;
>end;
>v1=emply;
> if visitnum ne '00' then do;
> v1=emply;
> if jobchgyn=1 then do;
> if empcd ne . then emply=1;
> if empcd=. and unemcd ne . then emply=2;
> end;
> else if jobchgyn=0 then do;
> if empcd=. then emply=1;
> else if emply ne . and empcd=. then v1=emply;
> else emply=v1;
>end;
>
> else if jobchgyn=. and empcd ne . then emply=1;
> end;
> run;
>proc print;run;
>
>please guide me how to create that variable correctly ,
>Thanks & Regards,
>Vijay
|