Date: Thu, 10 Nov 2005 07:34:41 -0800
Reply-To: newuser <chenlse@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: newuser <chenlse@GMAIL.COM>
Organization: http://groups.google.com
Subject: macro questions
Content-Type: text/plain; charset="iso-8859-1"
Hi, everyone,I have a problem writing macro program.
I have data with two variables: date and price.
I want to multiply all the "price" observations from after the 'drop
time' by 2 when there is a big drop in it compared to the last
observation.
for example, the raw data is:
date price
10-12-1992 13
10-13-1992 13
10-14-1992 13
10-15-1992 6
10-16-1992 7
10-17-1992 7
10-18-1992 3
10-19-1992 3
And I want to get:
10-12-1992 13
10-13-1992 13
10-14-1992 13
10-15-1992 12
10-16-1992 14
10-17-1992 14
10-18-1992 12
10-19-1992 12
but it is not working properly. Below is my program:
/* below, I record the number of times of 'big drop' in price
and the happening time */
data _null_;
set temp;
retain lp i( 0 0);
if price<lp then do;
i=i+1;
call symput('sd'||left(i),date);
call symput('sn',put(i));
end;
lp=price;
run;
%global mj;
%let mj=0;
%macro loop(cdate=);
%let mj=0;
%do v=1 %to &sn;
%if &cdate>=&&sd&v %then %let mj=&v;
%end;
%mend;
data temp_1;
set temp;
%loop(cdate=date);
price=price*(2**(&mj));
run;
Thank you!!
chen