Hi, I just did a practice of array and happened to find that one arithmetic result is not logical. **** data preparation ;
data visits;
infile datalines;
input patid visdt0 visdt1 visdt2 visdt3 visdt4;
datalines;
1001 0.1 1.1 2.1 3.1 4.1
1002 0.2 1.2 2.2 3.2 4.2
;
run;
**** foolproof dataset;
data work.checkvisits;
set work.visits (keep=patid visdt0 visdt1 visdt2 visdt3 visdt4);
array visdt(1:5) visdt0 visdt1 visdt2 visdt3 visdt4;
do i=2 to 5;
x = visdt(i) - visdt(i-1);
if x gt 1 then do;
* there should be no output since all differences;
* should equal to 1 ;
put visdt(i-1)= visdt(i)= x=;
output;
end;
end;
drop i x;
run;
**** print ;
proc print data=checkvisits;
run; and the log: ```log visdt1=1.2 visdt2=2.2 x=1 NOTE: There were 2 observations read from the data set WORK.VISITS. NOTE: The data set WORK.CHECKVISITS has 1 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds ``` The environment is SAS 9.2 on Linux. Please advise, thanks.
... View more