Hey SAS Experts,
Please correct my understanding of the PDV in the below code:
The program runs perfectly fine.
data have;
input id $ date value holddate holdvalue lastdate lastvalue;
informat date holddate lastdate ddmmyy10.;
format date holddate lastdate ddmmyy10.;
datalines;
A 7/10/2014 11840 7/10/2014 11840 4/10/2014 15280
;
data need;
set have;
if date ne lastdate+1 then do date=lastdate+1 to holddate-1;
value=lastvalue;
output;
end;
putlog _all_; /* I tried looking at the PDV details, still haven't understood though */
value=holdvalue;
lastdate=date;
lastvalue=value;
output;
run;
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.
Many thanks,
Charlotte
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.
Xia Keshan
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..
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.