Date: Mon, 24 Mar 2008 15:01:17 -0500
Reply-To: "data _null_," <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_," <datanull@GMAIL.COM>
Subject: Re: Marking the values
In-Reply-To: <200803241958.m2OAmMCU002874@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
But the values of COL1-COL5 need to become the variable names.
id a b c d e
1 X X X X X
2 X X
3 X
4 X X X
5 X
6 X X
On Mon, Mar 24, 2008 at 2:58 PM, Ya Huang <ya.huang@amylin.com> wrote:
> Or we can use format:
>
> proc format;
> value $x 'a'-'z'='X';
> run;
>
> data need;
> set have;
> array x $ col1-col5;
> do over x;
> x=put(x,$x.);
> end;
> run;
>
> proc print;
> run;
>
> id col1 col2 col3 col4 col5
>
> 1 X X X X X
> 2 X X
> 3 X
> 4 X X X
> 5 X
> 6 X X
>
>
> On Mon, 24 Mar 2008 14:12:40 -0500, data _null_, <datanull@GMAIL.COM> wrote:
>
> >Maybe we could call this an "out and back" double transpose. If you
> >have a reasonably modest amount of data and don't want to think to
> >hard this seems like a reasonable solution. Of course the values of
> >COLn need to be SAS names as in your example.
> >
> >data have;
> > input id 1. (col1-col5) ($1.);
> > cards;
> >1abcde
> >2ae
> >3c
> >4abc
> >5e
> >6ac
> >;;;;;
> > run;
> >proc transpose out=out;
> > by id;
> > var col:;
> > run;
> >proc transpose out=andBack;
> > by id;
> > var col1;
> > id col1;
> > run;
> >proc print;
> > run;
> >
> >On Mon, Mar 24, 2008 at 2:01 PM, Peter Narasimha <bmepavan@gmail.com>
> wrote:
> >> Hello All,
> >> I have a dataset which looks like this
> >> data have;
> >> input id col1-col5$.;
> >> cards;
> >> id col1 col2 col3 col4 col5
> >> 1 a b c d e
> >> 2 a e
> >> 3 c
> >> 4 a b c
> >> 5 e
> >> 6 a c
> >> ;
> >> run;
> >> I need to create a dataset which looks like this
> >>
> >> id a b c d e
> >> 1 X X X X X
> >> 2 X X
> >> 3 X
> >> 4 X X X
> >> 5 X
> >> 6 X X
> >>
> >> Basically I need to mark those that are present..Can anyone help me??
> >> Thanks,
> >> Peter
> >>
>
|