Loops can be created in many different ways and for many different purposes, but based on your very brief description, I am going to assume that you are looking to create a loop that will create the same output for each value of a field and that you are using a "Select" node to select the records in each subset of your data. If this is not what you are looking for, then I think we will need some additional details from you.
The easiest way to achieve this is the use the built-in looping functionality of Modeler. From the menu select "Tools | Stream Properties | Execution ...". Set the "Execution Mode" to "Looping / Conditional Execution". This function is described in some detail in the Looping in streams section of the Modeler Help, but I do find that it is lacking a good example.
These are the steps that I used to create the sample stream that I have attached:
Create a stream parameter from the "Parameter" tab of the Stream Options. I have called mine "selected_income_level"
This stream parameter is then used in the condition of the "Select node:
'Income level' = '$P-selected_income_level'. This is how each subset of the dataset is selected.
Create a Create an "Iteration Key" from the "Iteration Key..." button.
Set the "Iterate on:" option to "Stream Parameter - Values". This will instruct the loop to change the value of a stream parameter with each loop.
In the "What to Set - Parameter:" select the parameter that you created in step 1.
For the "Values to Use" there are several selections to make. First you pick the node at which the loop should be active. In the "Node:" selection, I picked the "Select" node named "Income Level".
I then pick the field over which I want to loop; in this case the "Income level".
Finally, I populate the "Value list". This can either be done manually by typing in each value that you wish to iterate over or you can get the values from the instantiation in Modeler by using the first of the three buttons to the right of the list with the numbers 1, 5, and 3 in it.
When executing the stream, you will now get a "Distribution" chart for each income level showing the distribution between individuals with Good and Bad credit for the individuals at the Income Level.
You can choose to save the data from each segment into separate worksheets within the same Excel Workbook or you can save it to separate Excel Workbooks entirely. You can also choose the save the data to (an) existing Workbook(s) or create new ones.
Whatever you are looking to do, however, this requires several changes within each loop and this is beyond the limits of the "Looping / Conditional Execution" functionality made available through the GUI. You have thus wondered into the world of scripting, but the "Looping / Conditional Execution" function can give you a jump start.
Use the "Paste" button in the bottom right corner to paste the underlying scripting commands to the default scripting window. You can now use this as the starting point and include any additional scripting commands that you need.
The "Excel Export" node has a number of different properties that are described in the excelexportnode Properties article in the IBM SPSS Modeler Help.
stream = modeler.script.stream() iterationKey_StreamParameter = u"selected_income_level" iterationKey_NodeValues = [u'Low',u'Medium',u'High'] iterationKey_NodeID = "id2VLRR42NFP9" # "Excel":excelexport iterationKey_NodeProperty = "full_filename" for i in range(len(iterationKey_NodeValues)): # initialize iteration key value = iterationKey_NodeValues[i] stream.setParameterValue(u"$P-selected_income_level",value) node = stream.findByID(iterationKey_NodeID) node.setPropertyValue(iterationKey_NodeProperty,value) # Now execute the stream for this iteration executionResults =  stream.runAll(executionResults) print "Execution completed."
The amended script above will loop through each value of the "Income level" field and save a new Excel Workbook in the default folder for each as well as create the original distribution chart. This is included in the attached stream.