I agree with my good friend @yabwon more than copilot, but still want to add something / try explaining differently.
When you use a SET statement, the variables read in on that SET statement are automatically retained.
When you use a SET statement to concatenate datasets e.g.:
set c2 c3;
you would not want a value read from the last record of c2 to be retained, and be applied to every record in c3. Therefore the SET statement sensibly has a rule: whenever it reads from a new dataset, it resets the variables read by the SET statement to missing before reading the first record of the new dataset. (It doesn't actually reset the full PDV).
Note that the rule about when to reset variables to missing applies to each SET statement independently.
I would say:
During compile time, both SET statements are compiled, and both SET statements are going to read in the variables NAME and AGE. So they are retained.
_N_=1
1) Before reading the first record from C2, the first SET statement resets NAME and AGE to missing. Then it reads the first record of C2, which gives Name the value 'Alfred'.
2) Before reading the first record from C3, the second SET statement resets NAME and AGE to missing. Then it reads the first record of C3, which gives Age the value 14.
_N_=2
1) The first SET statement will read the second record from C2. Because this is not a new dataset (i.e. the prior record was also read from C2), no variables are reset to missing. The SET statement reads the second record of C2, gives Name the value 'Alice.'
2) the second SET statement will read the second record from C3. Because this is not a new dataset (i.e. the prior record was also read from C3), no variables are reset to missing. The SET statement reads the second record of C3, gives Age the value 13.
_N_=3
1) The first SET statement will read the third record from C2. Because this is not a new dataset (i.e. the prior record was also read from C2), no variables are reset to missing. The SET statement reads the second record of C2, gives Name the value 'Barbara.'
2) the second SET statement will read the third record from C3. Because this is not a new dataset (i.e. the prior record was also read from C3), no variables are reset to missing. The SET statement reads the third record of C3, gives Age the value 13.
_N_=4
1) The first SET statement will read the first record from C3. Because this *is* a new dataset (i.e. the prior record was read from C2), Name and Age are reset to missing. The SET statement reads the first record of C3, gives Age the value 14.
2) the second SET statement will read the first record from C2. Because this *is* a new dataset (i.e. the prior record was read from C3), Name and Age are set to missing. The SET statement reads the first record of C2, gives Name the value 'Alfred'.
... View more