Date: Tue, 4 Feb 2003 13:39:42 -0800
Reply-To: Mark Terjeson <mark.terjeson@NWCSR.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mark Terjeson <mark.terjeson@NWCSR.COM>
Subject: Re: Problem
In-Reply-To: <80d9e10e.0302041252.4af46d9a@posting.google.com>
Content-Type: text/plain; charset="us-ascii"
Hi,
Here is one possibility.
I threw in an extra in one year just
in case that needed to be covered.
data Table1;
input uid $ year;
cards;
x 1999
x 2000
x 2000
y 2001
x 2001
y 2002
x 2002
;
run;
proc sql;
create table Table2 as
select
uid,
count(uid) as count,
year
from
Table1
group by
year,uid
order by
uid,year
;
quit;
proc transpose data=Table2 out=Table3(drop=_name_);
by uid;
id year;
var count;
run;
Hope this is helpful,
Mark Terjeson
Northwest Crime and Social Research, Inc.
A SAS Alliance Partner
215 Legion Way SW
Olympia, WA 98501
360.870.2581 - voice,cell
360.570.7533 - fax
mailto:mark.terjeson@nwcsr.com
www.nwcsr.com
"Nothing is particularly hard
if you divide it into small jobs."
- Henry Ford, Industrialist
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Jishnu
Sent: Tuesday, February 04, 2003 12:52 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Problem
Hi does any body how to solve this isssue:
Original Dataset
uid year
x 1999
x 2000
y 2001
x 2001
y 2002
x 2002
I would like to transform it into
99 00 01 02
1 1 1 1
1 1
Since x originated on 1999 that is why 99 gets 1 and stays on till the
year is available
Since y is originated in 2001 it gets a 1 at 2001.
Thank you