| Date: | Tue, 3 Apr 2007 10:58:01 -0400 |
| Reply-To: | "data _null_;" <datanull@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "data _null_;" <datanull@GMAIL.COM> |
| Subject: | Re: Data Step question |
|
| In-Reply-To: | <809BA36B4233FB4190D6D5A4C8BFA6610141DB06@KENMSG26.us.schp.com> |
| Content-Type: | text/plain; charset=ISO-8859-1; format=flowed |
If I understand correctly then parhaps just setting some flags and
then merging back to subset will work.
The SQL experts can show you how to do this in one step.
Data work.lab;
input patno $5. visit 1. lo:6.2 hi:6.2 rslt:6.2;
if not missing(rslt) then lowFlag = rslt lt lo;
if not missing(rslt) then highLT10 = rslt gt hi and rslt lt 10;
if not missing(rslt) then highGT10 = rslt gt 10;
cards;
000011 .32 5.0000 0.20
000012 .32 5.0000 8.76
000013 .32 5.0000 95.50
000021 .32 5.0000 .24
000022 .32 5.0000 .31
000023 .32 5.0000 .33
;;;;
run;
proc print;
run;
proc summary data=work.lab nway missing;
class patno;
var lowFlag highLT10 highGT10;
output out=work.flags(drop=_:) max=;
run;
data work.labSubset;
merge work.lab(drop=lowFlag high:) work.flags;
by patno;
if lowFlag and not(highLT10 or highGT10);
run;
proc print;
run;
On 4/3/07, Sridhar, Nagakumar <nagakumar.sridhar@spcorp.com> wrote:
> Hi All:
> I am trying to do the following:
>
> I need to get data from a dataset that fulfills certain conditions. I
> need to make sure that if the a patient has low values in one visit and
> high(er than the upper limit) values in the next, they (all values for
> that patient, regardless of whether they're lower or higher than the
> lower/higher ranges) get grouped into one dataset. The problem is
> that certain patients could have low values at one visit but very high
> values in the next visit. But, they also should meet certain criteria:
> These are:
>
> Lowest value < = lower limit of range (exclude those subjects
> that then fit into the categories below)
> Highest value > upper limit of range but less than 10
> Highest value > 10
>
> Data have; /* JUST AN EXAMPLE OF WHAT THE DATA LOOKS LIKE. THERE ARE
> ABOUT 3000 MORE PATIENTS*/
> input patno $5. visit 1. lo 6. 2 hi 6.2 rslt 6.2;
> cards;
> 000011 .32 5.0000 0.20
> 000012 .32 5.0000 8.76
> 000013 .32 5.0000 95.50
> 000021 .32 5.0000 .24
> 000022 .32 5.0000 .31
> 000023 .32 5.0000 .33
> ;
>
> What I need is:
>
> 000021 .32 5.0000 .24
> 000022 .32 5.0000 .31
> 000023 .32 5.0000 .33
>
>
> I hope I haven't confused you more than I usually do.
>
> TIA
>
> Kumar
>
> *********************************************************************
> This message and any attachments are solely for the
> intended recipient. If you are not the intended recipient,
> disclosure, copying, use or distribution of the information
> included in this message is prohibited -- Please
> immediately and permanently delete.
>
|