Hi:
I'd suggest you look for this documentation topic:
STATEMENTS: Output Statement which explains (in short) that the OUTPUT statement: "Writes the current observation to a SAS data set." The doc has a lengthy explanation and at least 4 examples of using the OUTPUT statement.
If the OUTPUT statement is placed inside an IF statement, then the OUTPUT statement will be executed conditionally (and, thus, write observations conditionally). Depending on how many OUTPUT statements you have inside IF statements in the whole program, you might see a different number of observations coming OUT of the DATA step program than the number of observations that are being read INTO your program.
cynthia