Re: Generate rows per a column value

Haikuo, may be I am missing something important. When data step reads Sue, isn't _n_ becomes 2. What is logic behind "do group" starting form _n_=1? I am assuming when _n_=2 it is asking to iterate to 2 (Num_chances). So there is interplay of two kinds of _n_? when I put index "i" instead of _n_, it gives same result.

Re: Generate rows per a column value

I admit this is not conventional use of '_n_' and it does inherit some risks if you are not completely sure about its inandout. The only reason I choose to do so is my laziness. The normal way to do it is to initiate a non-automatic variable as index, then drop it after the use.

Here is what going on:

1. _n_ is automatic numeric variable that will not go to the output table, it does not need to be dropped, a potential to save some typing.

2. You already knew that _n_ will +1 for every data step implicit loop. What you are not aware is that it restored its counts from last loop and plus 1 when new loop starts.

3. Anywhere between data step implicit loops, _n_ is just a normal numeric variable that can be used as one, meaning you can assign values and use it as a index for a inner loop. When next round of data step implicit loop starts, _n_ will be back into playing its meant-to- be roles.