Answering question 1.
I think you are dealing with the compile-time vs run-time dilema.
To create a macro var from within a datastep (run-time), you should use the call symput statement.
the %let statement does the same at compile-time.
Answering question 2.
Yes, on your second example j is a macro var from compile-time.
Answering question 3.
From the syntax point of view, yes. Your code is correct.
You are building 5 step cycle if-then within a 10 step cycle datastep (10x5 cycles)
So you will get 10 datasteps with 5 if-then statements in each.
Cheers from Portugal.
Daniel Santos @
www.cgd.pt