The answer to your question is more complex than you might imagine. First, here are the principles involved. The DATA step operates in two phases. First, the software checks through all your DATA step statements, checks for syntax errors, and performs the set-up work (such as setting up storage locations for each variable). Once that is complete, it enters the second phase, which is actually executing your statements. The DIM function executes in phase 2, when all the DATA step statements are executing. But the software needs to know how many elements are in the array as part of phase 1 (set-up). So the DIM function doesn't execute in time, generating the error in phase 1. The solution is not particularly lengthy. Set up an initial DATA step to capture the number of elements in the array, then use that number later. For example: data _null_; set sasuser.class; array one{*} _character_; call symputx('n_cvars', dim(one)); stop; run; Then in the second DATA step: array two {&n_cvars} b_1 - b_&n_cvars; Hope this is clear enough. Good luck. Tom, you're fast. Looks like great minds think alike.
... View more