Possible Duplicate:
SAS proc SQL and arrays
I am trying to calculate the ratios of multiple columns, multiple times in SAS using SQL. For example, I want:
(((start*start_period)+(middle*middle_period)+(end*end_period))/number_days) AS azmonth;
The problem is that while start_period
, middle_period
, end_period
, and number_days
are constant and start
, middle
, and end
are one set of about 7 sets that need to be multiplied in the same way. Is there a way besides typing it out for each of them?
I know I can do a seperate equation for each of the Start, Mid, and Ends but i was hoping there was a way I could do it without having to copy/paste edit al of them individually?
Start1
supposed to multiply? What do you want the result for this line of input to be - itzy 2012-04-06 19:08
Write a macro before you run PROC SQL to generate the repetitive code for you, then call the macro at the appropriate point within proc SQL. If you were doing this in a data step instead, an alternative option would be to define 3 arrays for the start, middle and end variables and then repeat the calculation 20 times using a do loop.
As seen here.
This source claims that there is no looping capability within PROC SQL itself - I'm not sure whether this is true or not. If it is, a macro may be the only solution.