Apologies in advance if my description is not clear enough. Basically looking to add up columns in a dataframe with numeric suffix like a1, a2,a3 but would like the summation to be based on values in another column labelled say Indicator with values like 1,2,3. For example if column Indicator is equal to 2 then I will like to add up columns a2 and a3 since the suffix of the column names is >= column Indicator value of 2.
Tried to do this in SAS but did not work
This is a straight forward application of an ARRAY. First define the array with all of the variables. The use the extra variable as the starting point for the DO loop to do the summation.