LoopWhile --------- LoopWhile iterates over a set of commands under the control of one or more logical expressions. Since the logical conditions typically depend upon values in the data, commands executed in a LoopWhile cannot be anticipated and expanded in SDTL. Properties ~~~~~~~~~~ .. csv-table:: :header: "Name","Type","","Description" :widths: 15,10,5,100 "Condition",":doc:`/composite-types/ExpressionBase/index`","0..1","Describes a condition required for the next iteration to begin. " "EndCondition",":doc:`/composite-types/ExpressionBase/index`","0..1","Describes a condition that ends interation. " "Commands",":doc:`/composite-types/CommandBase/index`","1..n","Commands within the loop." "Updated","`boolean `_","0..1","When TRUE, the loop has been expanded into separate commands." Properties Inherited from TransformBase ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. csv-table:: :header: "Name","Type","","Description" :widths: 15,10,5,100 "ProducesDataframe",":doc:`/composite-types/DataframeDescription/index`","0..n","Signify the dataframe which this transform produces." "ConsumesDataframe",":doc:`/composite-types/DataframeDescription/index`","0..n","Signify the dataframe which this transform acts upon." Properties Inherited from CommandBase ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. csv-table:: :header: "Name","Type","","Description" :widths: 15,10,5,100 "Command","`string `_","1..1","The type of command" "SourceInformation",":doc:`/composite-types/SourceInformation/index`","0..n","Information about the source of the command." "MessageText","`string `_","0..n","Adds a message that can be displayed with the command." Item Type Hierarchy ~~~~~~~~~~~~~~~~~~~ * :doc:`/composite-types/CommandBase/index` * :doc:`/composite-types/TransformBase/index` * **LoopWhile** Relationships ~~~~~~~~~~~~~ The following identified item types reference this type. .. container:: image |stub| .. |stub| image:: ../../images/LoopWhile.svg SPSS_example_LoopWhile ~~~~~~~~~~~~~~~~~~~~~~ .. raw:: html

========= SPSS EXAMPLE ================

LOOP IF (Y GT 10). COMPUTE X=X+1. END LOOP IF (X EQ 5).

{"Command": "LoopWhile",
         "sourceInformation": {
            "originalSourceText": "LOOP IF (Y GT 10). 
   								COMPUTE X=X+1.
   								END LOOP IF (X EQ 5). "
   							},
   "Condition": 
   				{"$type":"FunctionCallExpression",
   				"Function": "gt",
   				"IsSDTLName":"True",
   				"Arguments": [
   					{"ArgumentName": "EXP1",
   					"ArgumentValue": 
   						{"$type": "VariableSymbolExpression",  "VariableName": "Y"}
   					},
   					{"ArgumentName": "EXP2",
   					"ArgumentValue": 
   						{"$type": "NumericConstantExpression",  "Value": "10"}
   					}
   				]
   				},
   "EndCondition":
   				{"$type":"FunctionCallExpression",
   				"Function": "eq",
   				"IsSDTLName":"True",
   				"Arguments": [
   					{"ArgumentName": "EXP1",
   					"ArgumentValue": 
   						{"$type": "VariableSymbolExpression",  "VariableName": "X"}
   					},
   					{"ArgumentName": "EXP2",
   					"ArgumentValue": 
   						{"$type": "NumericConstantExpression",  "IteratorSymbolName": "5"}
   					}
   				]
   				},
   "IteratorCommands:" [
   	   {"Command": "compute",
           "VariableName": 
   			{"$type": "VariableSymbolExpression",  "VariableName": "X"},
           "Expression": 
   		{"$type":"FunctionCallExpression",
   		   "Function": "Addition",
   		   "IsSDTLName":"True",
   		   "Arguments": [
   		   {"ArgumentName": "EXP1",
   		   "ArgumentValue": 
   				{"$type": "VariableSymbolExpression",  "VariableName": "X"},
   				},
   		   {"ArgumentName": "EXP2",
   		   "ArgumentValue": 
   				{"$type": "NumericConstantExpression",  "IteratorSymbolName": "1"}
   			}
   			]
   		}
   		}
       ]
   
   }
   
   
Stata_example_LoopWhile ~~~~~~~~~~~~~~~~~~~~~~~ .. raw:: html

======== Stata EXAMPLE ===============

while `i'<40 {
   	gen newvar`i' = runiform()
   	local i=`i'+1
   	}
   
{"Command": "LoopWhile",
         "sourceInformation": {
            "originalSourceText": "while `i'<40 {
   								gen newvar`i' = runiform()
   								local i=`i'+1
   								}"
   							},
   "Condition": 
   				{"$type":"FunctionCallExpression",
   				"Function": "lt",
   				"IsSDTLName":"True",
   				"Arguments": [
   					{"ArgumentName": "EXP1",
   					"ArgumentValue": 
   						{"$type": "IteratorSymbolExpression",  "IteratorSymbolName": "i"}
   					},
   					{"ArgumentName": "EXP2",
   					"ArgumentValue": 
   						{"$type": "NumericConstantExpression",  "Value": "40"}
   					}
   				]
   				},
   "IteratorCommands:" [
   	   {"Command": "compute",
           "VariableName": 
   			{"CompositeVariableName": 
   				{"Stub": "newvar",
   				 "Postfix": 
   					{"$type": "IteratorSymbolExpression",  "IteratorSymbolName": "i"}
   					}
   				},
   		"Expression": 
   		{"$type":"FunctionCallExpression",
   		   "Function": "random_variable_uniform",
   		   "IsSDTLName":"True",
   		   "Arguments": [
   		   {"ArgumentName": "EXP1",
   		   "ArgumentValue": 
   				{"$type": "NumericConstantExpression",  "Value": "0"},
   				},
   		   {"ArgumentName": "EXP2",
   		   "ArgumentValue": 
   				{"$type": "NumericConstantExpression",  "Value": "1"}
   			}
   			]
   		}
   		}
       ]
   
   }