Hello @SAIKDE,
The values of variable value1 are explained in section "How SAS Identifies the Beginning and End of a BY Group" of the documentation of the BY statement:
SAS sets the value of FIRST.variable to 1 when it reads the first observation in a BY group
and in subsection "How SAS Determines FIRST.variable and LAST.variable" of the section "FIRST. and LAST. DATA Step Variables" in the documentation "BY-Group Processing in the DATA Step":
For all other observations in the BY group, the value of FIRST.variable is 0.
It is the SET statement which reads the observations, so only after the execution of the SET statement variable first.clmv is updated for the current observation.
The values of variable value are explained by the facts that variables first.variable and last.variable are
initialized to 1 at the beginning of the DATA step
automatically retained (i.e., not set to missing when the DATA step iterates)
(which seem to be not clearly stated in the documentation linked above).
... View more