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

Name

Type

Description

Condition

ExpressionBase

0..1

Describes a condition required for the next iteration to begin.

EndCondition

ExpressionBase

0..1

Describes a condition that ends interation.

Commands

CommandBase

1..n

Commands within the loop.

Updated

boolean

0..1

When TRUE, the loop has been expanded into separate commands.

Properties Inherited from TransformBase

Name

Type

Description

ProducesDataframe

DataframeDescription

0..n

Signify the dataframe which this transform produces.

ConsumesDataframe

DataframeDescription

0..n

Signify the dataframe which this transform acts upon.

Properties Inherited from CommandBase

Name

Type

Description

Command

string

1..1

The type of command

SourceInformation

SourceInformation

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

Relationships

The following identified item types reference this type.

stub

SPSS_example_LoopWhile

========= 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

======== 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"}
                     }
                     ]
             }
             }
    ]

}