From: Al on


Dear All:

I have two datasets Lab , AE

Lab
Pat lab Day
1 BUN 1
1 BUN 23
1 BUN 30
1 BUN 46
1 BUN 56

AE
Pat Seq Day_AE
1 1 19
1 2 29
1 3 40
1 4 43
1 5 50

This is what I am trying to do .. I am trying to create a dataset with
columns Day1 Day23 Day20 Day46 Day56 (The names of these columns are
the values of Day column in Lab data) and under these columns I
should be able to have the values of Day_AE from AE data in such a
way that

1<Day_AE<=23 must fall under Day 23 column below

23<Day_AE<=30 must fall under Day 30 column below

30<Day_AE<=46 must fall under Day 46 column below

46<Day_AE<=56 must fall under Day 56 column below

Again the range values are from the Day column in the Lab data


Pat seq Day 1 Day23 Day 30 Day 46 Day 56
1 1 X
1 2 X
1 3 X
1 4 X
1
5
X

This is the matrix I am trying to get and I got it but the problem is
I want to try this on any values of pat .. and Day values in the Lab
data varies for different values of pat .. can this be done using a
macro??



Thanks in advance
Al

From: Ya on
On Jun 11, 8:19 pm, Al <ali6...(a)gmail.com> wrote:
> Dear All:
>
> I have two datasets  Lab , AE
>
> Lab
> Pat  lab     Day
> 1     BUN     1
> 1     BUN     23
> 1     BUN     30
> 1     BUN     46
> 1     BUN     56
>
> AE
> Pat     Seq       Day_AE
> 1         1               19
> 1         2               29
> 1         3               40
> 1         4               43
> 1         5               50
>
> This is what I am trying to do .. I am trying to create a dataset with
> columns Day1 Day23 Day20 Day46 Day56 (The names of these columns are
> the values of Day column in Lab data) and under these columns   I
> should be able to have the values of  Day_AE from AE data in such a
> way that
>
> 1<Day_AE<=23  must fall under Day 23 column below
>
> 23<Day_AE<=30  must fall under Day 30 column below
>
> 30<Day_AE<=46  must fall under Day 46 column below
>
> 46<Day_AE<=56  must fall under Day 56 column below
>
> Again the range values are from the Day column in the Lab data
>
> Pat  seq  Day 1     Day23    Day 30         Day 46           Day 56
> 1     1                        X
> 1     2                                       X
> 1     3                                                        X
> 1     4                                                        X
> 1
> 5
> X
>
> This is the matrix I am trying to get  and I got it but the problem is
> I want to try this on any values of pat .. and  Day values in the  Lab
> data varies for different values of pat .. can this be done using a
> macro??
>
> Thanks in advance
> Al

data lab;
set lab;
day_ae=day;
run;

/* sort both by pat and day as needed */

data labae;
merge lab ae(in=b_);
retain labday;
by pat day_ae;
if first.pat then labday=.;
if ^missing(day) then labday=day;
else day=labday;
ae='x';
if b_;
run;

proc transpose data=labae out=tran (drop=_name_) prefix=Day;
by pat seq;
var ae;
id labday;
run;

proc print;
run;

Pat Seq Day1 Day23 Day30 Day46

1 1 x
1 2 x
1 3 x
1 4 x
1 5 x

HTH

Ya
From: Al on
On Jun 13, 10:30 am, Ya <huang8...(a)gmail.com> wrote:
> On Jun 11, 8:19 pm, Al <ali6...(a)gmail.com> wrote:
>
>
>
>
>
> > Dear All:
>
> > I have two datasets  Lab , AE
>
> > Lab
> > Pat  lab     Day
> > 1     BUN     1
> > 1     BUN     23
> > 1     BUN     30
> > 1     BUN     46
> > 1     BUN     56
>
> > AE
> > Pat     Seq       Day_AE
> > 1         1               19
> > 1         2               29
> > 1         3               40
> > 1         4               43
> > 1         5               50
>
> > This is what I am trying to do .. I am trying to create a dataset with
> > columns Day1 Day23 Day20 Day46 Day56 (The names of these columns are
> > the values of Day column in Lab data) and under these columns   I
> > should be able to have the values of  Day_AE from AE data in such a
> > way that
>
> > 1<Day_AE<=23  must fall under Day 23 column below
>
> > 23<Day_AE<=30  must fall under Day 30 column below
>
> > 30<Day_AE<=46  must fall under Day 46 column below
>
> > 46<Day_AE<=56  must fall under Day 56 column below
>
> > Again the range values are from the Day column in the Lab data
>
> > Pat  seq  Day 1     Day23    Day 30         Day 46           Day 56
> > 1     1                        X
> > 1     2                                       X
> > 1     3                                                        X
> > 1     4                                                        X
> > 1
> > 5
> > X
>
> > This is the matrix I am trying to get  and I got it but the problem is
> > I want to try this on any values of pat .. and  Day values in the  Lab
> > data varies for different values of pat .. can this be done using a
> > macro??
>
> > Thanks in advance
> > Al
>
> data lab;
>  set lab;
> day_ae=day;
> run;
>
> /* sort both by pat and day as needed */
>
> data labae;
> merge lab ae(in=b_);
> retain labday;
> by pat day_ae;
> if first.pat then labday=.;
> if ^missing(day) then labday=day;
> else day=labday;
> ae='x';
> if b_;
> run;
>
> proc transpose data=labae out=tran (drop=_name_) prefix=Day;
> by pat seq;
> var ae;
> id labday;
> run;
>
> proc print;
> run;
>
> Pat    Seq    Day1    Day23    Day30    Day46
>
>  1      1      x
>  1      2               x
>  1      3                        x
>  1      4                        x
>  1      5                                 x
>
> HTH
>
> Ya- Hide quoted text -
>
> - Show quoted text -

Hi Ya ::

Thanks for yout time .. but this is not want i wanted .. I may have
not explained the scenario correct .. let me try one more time ..i
want to create columns based on the values of day in the lab data and
in those columns ..i want to place values of day_ae from ae data..
such a way that

1<Day_AE<=23 must fall under Day 23 column

23<Day_AE<=30 must fall under Day 30 column

30<Day_AE<=46 must fall under Day 46 column

46<Day_AE<=56 must fall under Day 56 column ...


I ran your code but i dont seem to get 50 or X (from AE data ) under
day 56 column..


Thanks in advace
Al


From: Ya on
On Jun 13, 10:10 am, Al <ali6...(a)gmail.com> wrote:
> On Jun 13, 10:30 am, Ya <huang8...(a)gmail.com> wrote:
>
>
>
>
>
> > On Jun 11, 8:19 pm, Al <ali6...(a)gmail.com> wrote:
>
> > > Dear All:
>
> > > I have two datasets  Lab , AE
>
> > > Lab
> > > Pat  lab     Day
> > > 1     BUN     1
> > > 1     BUN     23
> > > 1     BUN     30
> > > 1     BUN     46
> > > 1     BUN     56
>
> > > AE
> > > Pat     Seq       Day_AE
> > > 1         1               19
> > > 1         2               29
> > > 1         3               40
> > > 1         4               43
> > > 1         5               50
>
> > > This is what I am trying to do .. I am trying to create a dataset with
> > > columns Day1 Day23 Day20 Day46 Day56 (The names of these columns are
> > > the values of Day column in Lab data) and under these columns   I
> > > should be able to have the values of  Day_AE from AE data in such a
> > > way that
>
> > > 1<Day_AE<=23  must fall under Day 23 column below
>
> > > 23<Day_AE<=30  must fall under Day 30 column below
>
> > > 30<Day_AE<=46  must fall under Day 46 column below
>
> > > 46<Day_AE<=56  must fall under Day 56 column below
>
> > > Again the range values are from the Day column in the Lab data
>
> > > Pat  seq  Day 1     Day23    Day 30         Day 46           Day 56
> > > 1     1                        X
> > > 1     2                                       X
> > > 1     3                                                        X
> > > 1     4                                                        X
> > > 1
> > > 5
> > > X
>
> > > This is the matrix I am trying to get  and I got it but the problem is
> > > I want to try this on any values of pat .. and  Day values in the  Lab
> > > data varies for different values of pat .. can this be done using a
> > > macro??
>
> > > Thanks in advance
> > > Al
>
> > data lab;
> >  set lab;
> > day_ae=day;
> > run;
>
> > /* sort both by pat and day as needed */
>
> > data labae;
> > merge lab ae(in=b_);
> > retain labday;
> > by pat day_ae;
> > if first.pat then labday=.;
> > if ^missing(day) then labday=day;
> > else day=labday;
> > ae='x';
> > if b_;
> > run;
>
> > proc transpose data=labae out=tran (drop=_name_) prefix=Day;
> > by pat seq;
> > var ae;
> > id labday;
> > run;
>
> > proc print;
> > run;
>
> > Pat    Seq    Day1    Day23    Day30    Day46
>
> >  1      1      x
> >  1      2               x
> >  1      3                        x
> >  1      4                        x
> >  1      5                                 x
>
> > HTH
>
> > Ya- Hide quoted text -
>
> > - Show quoted text -
>
> Hi Ya ::
>
> Thanks for yout time  ..  but this is not want i wanted .. I may have
> not explained the scenario correct .. let me try one more time ..i
> want to create columns based on the values of day in the lab data and
> in those columns ..i want to place values of day_ae from ae data..
> such a way that
>
> 1<Day_AE<=23  must fall under Day 23 column
>
>  23<Day_AE<=30  must fall under Day 30 column
>
>  30<Day_AE<=46  must fall under Day 46 column
>
>  46<Day_AE<=56  must fall under Day 56 column ...
>
> I ran your code but i dont seem to get 50 or X (from AE data ) under
> day 56 column..
>
> Thanks in advace
> Al- Hide quoted text -
>
> - Show quoted text -

In that case, we just need to sort "by pat descending day_ae":

proc sort data=ae;
by pat descending day_ae;
run;

data lab;
set lab;
day_ae=day;
run;

proc sort data=lab;
by pat descending day_ae;
run;

data labae;
merge lab ae(in=b_);
retain labday;
by pat descending day_ae;
if first.pat then labday=.;
if ^missing(day) then labday=day;
else day=labday;
ae='x';
if b_;
run;

proc sort;
by pat seq;
run;

proc transpose data=labae out=tran (drop=_name_) prefix=Day;
by pat seq;
var ae;
id labday;
run;

proc print;
run;

Pat Seq Day23 Day30 Day46 Day56

1 1 x
1 2 x
1 3 x
1 4 x
1 5 x
From: RolandRB on
On Jun 12, 5:19 am, Al <ali6...(a)gmail.com> wrote:
> Dear All:
>
> I have two datasets  Lab , AE
>
> Lab
> Pat  lab     Day
> 1     BUN     1
> 1     BUN     23
> 1     BUN     30
> 1     BUN     46
> 1     BUN     56
>
> AE
> Pat     Seq       Day_AE
> 1         1               19
> 1         2               29
> 1         3               40
> 1         4               43
> 1         5               50
>
> This is what I am trying to do .. I am trying to create a dataset with
> columns Day1 Day23 Day20 Day46 Day56 (The names of these columns are
> the values of Day column in Lab data) and under these columns   I
> should be able to have the values of  Day_AE from AE data in such a
> way that
>
> 1<Day_AE<=23  must fall under Day 23 column below
>
> 23<Day_AE<=30  must fall under Day 30 column below
>
> 30<Day_AE<=46  must fall under Day 46 column below
>
> 46<Day_AE<=56  must fall under Day 56 column below
>
> Again the range values are from the Day column in the Lab data
>
> Pat  seq  Day 1     Day23    Day 30         Day 46           Day 56
> 1     1                        X
> 1     2                                       X
> 1     3                                                        X
> 1     4                                                        X
> 1
> 5
> X
>
> This is the matrix I am trying to get  and I got it but the problem is
> I want to try this on any values of pat .. and  Day values in the  Lab
> data varies for different values of pat .. can this be done using a
> macro??
>
> Thanks in advance
> Al

I know this is not what you are asking for but to me it looks like you
are doing patient profiling and I have put in a lot of work into that
over the years, culminating in my graphical patient profiler I call
RGPP (Roland's Graphical Patient Profiler). You can download it from
my web site and play around with it. It is very flexible. In my humble
opinion, it is better than anything else on the market due to its
flexibility. The downside is you have to do quite a bit of work up
front to get it working the way you want. But to help with that I have
included coded example on how to report on some CDISC data.

http://www.datasavantconsulting.com/roland/