Option Explicit Sub Main ' This script splits the data file into n (random) groups' ' Where n is supplied by the user ' Posted to SPSSX-L list on 2004/03/23 by Raynald Levesque Dim strCmd As String Dim vNbPieces As Variant Dim lngNumCases As Long lngNumCases = objSpssApp.Documents.GetDataDoc(0).GetNumberOfCases If lngNumCases = 0 Then MsgBox ("You need to load data in Data Editor " & vbCrLf & "before running this script!",vbCritical) Exit Sub End If Do vNbPieces =InputBox("Split file in how many random pieces?", "Input # of pieces",2) If vNbPieces = "" Then Exit Sub Loop Until IsNumeric(vNbPieces) strCmd = strCmd & "COMPUTE draw=UNIFORM(1)." & vbCrLf strCmd = strCmd & "SORT CASES BY draw." & vbCrLf strCmd = strCmd & "COMPUTE groupnb=MOD($CASENUM," & vNbPieces & ")." & vbCrLf strCmd = strCmd & "EXECUTE." & vbCrLf strCmd = strCmd & "" & vbCrLf objSpssApp.ExecuteCommands (strCmd,False) End Sub