data example;
set example1;
retain _obs 0;
by site;
if first.site then _obs = 0;
_obs + 1;
run;
According to the code above, I am supposed to get an output dataset something like this: site _obs 100 1 100. 2 100. 3 200. 1 200. 2 300. 1 300. 2 300. 3 300. 4 But instead, I got an output without a proper order: site _obs 100 1 100. 2 100. 3 200. 1 200. 2 300. 3 300. 4 300. 5 300. 6 Supposedly, the variable _obs should reset to zero(0) when the first.site encounters, but it did not. I am not sure what's the problem with this. Is this a syntax error or a flaw in SAS? I would really appreciate your help. Thank you.
... View more