| Date: | Mon, 24 Mar 2008 13:03:00 -0700 |
| Reply-To: | "Huang, Ya" <Ya.Huang@AMYLIN.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Huang, Ya" <Ya.Huang@AMYLIN.COM> |
| Subject: | Re: Marking the values |
|
| In-Reply-To: | <7367b4e20803241301l5563a62p5141e47a9a5918fb@mail.gmail.com> |
| Content-Type: | text/plain; charset="US-ASCII" |
Sorry, I missed that part :-(
-----Original Message-----
From: data _null_, [mailto:datanull@gmail.com]
Sent: Monday, March 24, 2008 1:01 PM
To: Huang, Ya
Cc: SAS-L@listserv.uga.edu
Subject: Re: Marking the values
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
> >>
>
|