You need to aggregate the data first and then analyze it.
It sounds like you want to sum amounts by identifier (e.g., fund) and month/year. I’m assuming a dataset called TABLE1 with three variables: Identifier (ID), Date (DT), and Amount (AMT).
Here is the same example done with two different programming languages.
A. Run SQL in a relational database
Here is a SQL code for use with Microsoft SQL Server:
SELECT ID, STR(DATEPART(YYYY,DT)) + '-' + REPLACE(STR(DATEPART(MM,DT),2),' ','0') DT_NEW, SUM(AMT) AMT_NEW
FROM TABLE1
GROUP BY ID, STR(DATEPART(YYYY,DT)) + '-' + REPLACE(STR(DATEPART(MM,DT),2),' ','0')
ORDER BY ID, DT_NEW
B. Run an SVB script in STATISTICA
Here is STATISTICA Visual Basic (SVB) code that will create a new aggregated dataset:
Sub Main
Dim s1 As SpreadsheetEnd Sub
Dim s2 As Spreadsheet
Dim id1 As String
Dim id2 As String
Dim dt1 As String
Dim dt2 As String
Dim amt1 As Double
Dim amt2 As Double
Dim c1 As Long
Dim c2 As Long
'Reference input spreadsheet
Set s1 = ActiveDataSet
id1 = s1.Cells(1,1).Value
dt1 = Format(s1.Cells(1,2).Value,"yyyy") + "-" + Format(s1.Cells(1,2).Value,"mm")
amt1 = s1.Cells(1,3).Value
'Create new spreadsheet
Set s2 = s1.SubsetEx2("1-3",False,True,"","0","","")
'Populate new spreadsheet
c2 = 1
s2.Cells(c2,1).Value = id1
s2.Cells(c2,2).Value = dt1
s2.Cells(c2,3).Value = amt1
For c1 = 2 To s1.EntireRange.LastRowid2 = s1.Cells(c1,1).ValueNext c1
dt2 = Format(s1.Cells(c1,2).Value,"yyyy") + "-" + Format(s1.Cells(c1,2).Value,"mm")
amt2 = s1.Cells(c1,3).Value
If id1 <> id2 Or dt1 <> dt2 Thens2.AddCases c2, 1Else
c2 = c2 + 1
s2.Cells(c2,1).Value = id2
s2.Cells(c2,2).Value = dt2
s2.Cells(c2,3).Value = amt2
id1 = id2
dt1 = dt2s2.Cells(c2,3).Value = s2.Cells(c2,3).Value + amt2End If
s2.Visible = True




Reply With Quote