I have a question regarding time spent in loops.
I am analyzing larger amounts of production data, typically 1mio rows.
For each row, production captures the status (column Statusnummer).
If the status is "1", then I would like to calculate the values for actual ("ist") and set value("soll").
So I need to calculate 1mio rows. I am doing this a lot of times in my code, for different values.
Sometimes, the loops are fast (60seconds), sometimes they are vey (!) slow(more than one day! The processor still working at full load!).
All the columns are set to numeric and continuous, but I cannot figure out, why some loops are very slow.
I even checked if the cell contains missing values(see sample code); Still the code remains slow.
Any idea, what I am doing wrong?
Marten
Sample of the code, which is slow:
for(i=1,i<=NRows(dt),i++,(
if(dt:Statusnummer[i] == 1,(
if(!isMissing(dt:Drehzahl[i]) & !isMissing(dt:geschw[i]) ,(
ist = dt:Drehzahl[i];
soll = dt:SollDrehzahl[i];
dt:Soll_drehzahl[i] = soll;
dt:Ist_drehzahl[i] = ist;
dt:Maschinenleistung[i] = 100*ist/soll;
));
));
));