12-21-2014 07:34 AM
Hey SAS Experts,
Please correct my understanding of the PDV in the below code:
The program runs perfectly fine.
input id $ date value holddate holdvalue lastdate lastvalue;
informat date holddate lastdate ddmmyy10.;
format date holddate lastdate ddmmyy10.;
A 7/10/2014 11840 7/10/2014 11840 4/10/2014 15280
if date ne lastdate+1 then do date=lastdate+1 to holddate-1;
putlog _all_; /* I tried looking at the PDV details, still haven't understood though */
Where does it say in the program after the conditional do loop to get the date value to 7/10/2014 as it outputs exactly what is needed?I.e My point is after the execution of the do loop, shouldn't date have the value of 6/10/2014 in the PDV? how did it correctly change to 7/10/2014 after i.e during the execution of 2nd output statement?
I know I am breaking my head for something simple, but your quick help would mean a lot to me.
12-21-2014 08:45 AM
Very Interesting Question.
do date=lastdate+1 to holddate-1; <=> do date=lastdate+1 to holddate-1 by 1;
Maybe date will add one automatically when it reach holddate-1 . therefore date actually would be holddate-1+1 = holddate .
Anyway it is good know this about SAS syntax.
12-21-2014 09:50 AM
I think this illustrates how it works more clearly than your example. The index is incremented and then compared to stop leaving the value of I at 4 when the loop is finished. You could use UNTIL to make it stop and leave the index eq to stop..