Let say I have a table with 3 variable: var1, var2, var3 and another table of reference.
Now I want to create anothe variable: var4; var4 is computed from var1, var2 and var3 and the reference table.
I could create a macro to do that (for each line), but I dont know how to pass the value from the macro (a table) into a result. I wonder how can we do it by creating a function to get a value, not a macro?
I understand that if I can create a function like that (this function will include data step and proc summary), thing will be easy like:
var4 = myfunction(var1, var2, var3).
Update:
The table reference in my case is:
age range1 range2 range3
1 10 1 8
2 0 4 1
3 4 6 1
4 6 5 2
5 10 5 6
So I want my function to get like:
var4 = myfunction(var1, var2, var3), for example var1 = 2, var2 = 2, var3 = 5:
Take the sum of range2 (correspond to var1 = 2); from line 2 to line 5 (corrspond to var2= 2 and var3 = 5) and the result will be: 4 + 6 + 5 + 5.
Thanks in advance.
newvar = myfunction(column_number,first_row,last_row)
? – Tom