|
Thomas
Here is a solution which appears to meet your needs. I have commented out a
couple lines which you don't need plus I added a where statement which
discards cases of cret= -1. This discarding needs to happen before SAS
sets up the first. variable value. Otherwise, your assigment and if
statements may not work properly.
Nat Wooding
data mret;
input COID $ YR MON CRET ;
format cret 14.11;
*if cret; * get rid of the missing cret lines before you get to a data
step with first.mon;
cards;
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 .
26880N 2003 03 1.0459851132
26880N 2003 03 0.9772717489
26880N 2003 03 0.9767431378
26880N 2003 03 1
26880N 2003 03 0.9517978982
26880N 2003 03 0.9749986978
26880N 2003 03 1.0964602662
26880N 2003 03 0.9529324891
26880N 2003 03 1.0470675109
26880N 2003 03 0.9529324891
proc print;
DATA MRET2;
SET MRET (where =(cret ne .));
BY COID YR MON;
RETAIN MRET;
*IF CRET^=. THEN DO;
IF FIRST.MON THEN MRET=CRET;
ELSE mret=MRET*CRET;
IF LAST.MON THEN OUTPUT;
* END;
RUN;
proc print;
DATA MONTH_RET;
SET MRET2;
MONTH_RET=MRET-1;
*
KEEP CONAME COID DATE YR MON MONTH_RET;
proc print;
RUN;
Thomas
<tythong@YAHOO.CO To: SAS-L@LISTSERV.UGA.EDU
M> cc:
Sent by: "SAS(r) Subject: Re: Compound
Discussion"
<SAS-L@LISTSERV.U
GA.EDU>
02/23/05 10:54 AM
Please respond to
Thomas
Thanks Nigel.
You are right that I actually would like to compound the CRET with non-
missing values, and no matter whether the first observation, observations
in the middle, and/or last observation of CRET are missing.
May I know how to control all this in one statement? Is it possible to
combine the two statements I submitted to the list earlier into one?
Thanks again!
Thomas
|