06-25-2009 11:24 AM
06-25-2009 11:33 AM
06-26-2009 01:59 AM
06-26-2009 06:32 AM
06-26-2009 06:49 AM
06-26-2009 07:54 AM
06-29-2009 10:48 PM
The intend of the post [pre] do i=1 to n by 1;
put ....; /*here,how to use the string value of "col_name" as a column name?*/
[/pre]was obviously to put= the variables one by one, not to build a long string of all the names.
I reckon Scott's use of the colon
[pre] array a_cols (*) col: ; [/pre]is the most elegant way to deal transparently with the unknown number of columns.
After that, 3 ways to output the values are all good:
[pre] temp_var = vvaluex('col'||put(i,3. -l)); * we don't access the array here, but the variable directly;
temp_var1 = vvalue(a_cols(i));
I mentioned vvaluex() as an alternative because it is very useful, and too little known. Since we have an array in this case, it is no better than referencing the array directly (it is actually worse as there is an extra step to create a temporary variable), but it can access any variable name (not arrays only), and can replace macro code in some cases.