|
On Thu, 24 Jul 2008 17:31:46 -0700, learner <cnfengshuang@GMAIL.COM> wrote:
>Hi,
>
>What I want to do is like this. Suppose I have some data as below.
>
>id date value
>1 200801 100
>2 200802 101
>3 200803 99
>
>I want to create a new variable each time value>=100, with part of the
>variable name record the date. like this:
>
>id date value value_200801 value_200802
>1 200801 100 100 101
>2 200802 101 100 101
>3 200803 99 100 101
>
>I have a large data set to process like this, so please help me to
>find an easy way to do it. I am going to do numerical analysis for
>each id, and need to drop the added variables in the process of
>calculation before processing the next id, to save system resource.
>Can I do this in the DATA step? or is IML better?
>
>TIA
>Learner
Try this:
data have;
informat id $1. date yymmn6.;
format date yymm7.;
input
id date value ; cards;
1 200801 100
2 200802 101
3 200803 99
;
data ge100;
set have;
where value ge 100;
run;
proc transpose data=ge100 out=wide(drop=_name_) prefix=value_;
id date;
var value;
run;
data want;
set have;
if _n_=1 then set wide;
run;
|