Hello,

This is my first post. Please be forgiving.

I have written a couple of macros in Excel which reads through my data sequentially and jumps back to previous observations. For example:
Code:
Sub aggregate()

Dim count As Integer
Dim countstart As Integer
Dim aggregate As Double
Dim period As Integer
Dim agg As Double

period = 1

For period = 1 To 4
count = 2
countstart = 2
For count = 2 To 3950
    If Worksheets("output").Cells(count, 7).Value = Worksheets("output").Cells(count - 1, 7).Value Then
        aggregate = aggregate + Worksheets("output").Cells(count, 11).Value * Worksheets("output").Range("P1:S6438").Cells(count, period).Value * (1 - Worksheets("output").Cells(count, 20).Value)
        agg = agg + Worksheets("output").Cells(count, 11).Value * Worksheets("output").Range("P1:S6438").Cells(count, period).Value * Worksheets("output").Cells(count, 20).Value
        
    Else:
        Do Until countstart = count + 1
            If Worksheets("output").Range("P1:S6438").Cells(countstart, period).Value = 1 Then
                Worksheets("output").Range("V1:V6438").Cells(countstart, 1).Value = aggregate * (1 - Worksheets("output").Cells(countstart, 20).Value) + agg * (Worksheets("output").Cells(countstart, 20).Value)
            End If
            countstart = countstart + 1
        Loop
        countstart = count
        aggregate = Worksheets("output").Cells(count, 11).Value * Worksheets("output").Range("P1:S6438").Cells(count, period).Value * (1 - Worksheets("output").Cells(count, 20).Value)
        agg = Worksheets("output").Cells(count, 11).Value * Worksheets("output").Range("P1:S6438").Cells(count, period).Value * Worksheets("output").Cells(count, 20).Value

    End If
Next

Next

End Sub
I'm wondering whether I should try converting these into SAS or just perform these steps in Excel where necessary.
a) I have a lot of data. Many, many excel files are needed.
b) I need to match other data from other databases as well, which could be done in SAS.
c) Eventually, I need to perform statistical analysis on the data.

I'm not very familiar with SAS at all. I think I would transpose the data and then declare an array? Or is there some other way to explicitly reference each column, row?

Further, I think I would run out of columns if I have to transpose all my data in SAS.

Thanks in advance,
Sarah