Great! Glad you have a solution that works for you.
I'd like to clarify something for future reference. CALL SYMPUT executes on every iteration of the DATA step program to CREATE a macro variable -- at execution time (or in your case, for every iteration of the DO loop). An "&macvar" reference only gets resolved at COMPILE time. That means if you use CALL SYMPUT and an &macvar reference, you have a timing issue because the &macvar will be resolved, if possible BEFORE the CALL SYMPUT executes.
Usually, you don't CREATE a macro variable and then REFERENCE that macro variable with an &macvar reference in the same program.
&bobno will not be available for compile time resolution until after the creating datastep is over, as described here:
http://support.sas.com/kb/23/182.html
http://support.sas.com/kb/22/987.html
--and when it IS available, it will ALWAYS be whatever value was the LAST value assigned in the CALL SYMPUT -- which in your case would always be B5.
The documentation on CALL SYMPUT and SYMGET are here. The SYMGET doc has a good example of using SYMGET from a previously SYMPUT-created variable:
http://support.sas.com/documentation/cdl/en/mcrolref/59526/HTML/default/a000210266.htm
http://support.sas.com/documentation/cdl/en/mcrolref/59526/HTML/default/a000210322.htm
This program shows an interesting use of CALL SYMPUT and SYMGET that proves the macro variable 'bobno' is getting set appropriately for every iteration of the DO loop -- it also proves that at the end of the do loop, 'bobno' is set to B5. Usually, when you have a DO loop and a CALL SYMPUT, you are creating numbered macro variables (also shown):
[pre]
421 data play;
422
423 do i=1 to 5;
424 call symput ('bobno',compress('B'||i));
425 val = symget('bobno');
426 call symput ('bobno'||put(i,1.0),compress('B'||i));
427 put _all_;
428
429 end;
430
431 run;
NOTE: Numeric values have been converted to character values at the places given by:
(Line):(Column).
424:41 426:53
i=1 val=B1 _ERROR_=0 _N_=1
i=2 val=B2 _ERROR_=0 _N_=1
i=3 val=B3 _ERROR_=0 _N_=1
i=4 val=B4 _ERROR_=0 _N_=1
i=5 val=B5 _ERROR_=0 _N_=1
NOTE: The data set WORK.PLAY has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
432
433 %put after data step: bobno = &bobno;
after data step: bobno = B5
434 %put bobno1 = &bobno1;
bobno1 = B1
435 %put bobno2 = &bobno2;
bobno2 = B2
436 %put bobno3 = &bobno3;
bobno3 = B3
437 %put bobno4 = &bobno4;
bobno4 = B4
438 %put bobno5 = &bobno5;
bobno5 = B5
[/pre]
Note that when using SYMGET to create the variable VAL, VAL changes for every iteration of the DO loop; in a similar fashion VAL
would change on every iteration of a DATA step program. The usual way that macro variables are set in a DO loop are to use i as part of
the macro variable value (as shown). The FINAL value of bobno is B5...because at every iteration of the do loop, you are writing over the
previously set value.
cynthia