ReshapeWide ----------- ReshapeWide is not supported in the current version of SDTL, because it depends on values in the data. However, it may be useful when values of the index variable are available in the metadata file or the data can be processed. Properties ~~~~~~~~~~ .. csv-table:: :header: "Name","Type","","Description" :widths: 15,10,5,100 "MakeItems",":doc:`/composite-types/ReshapeItemDescription/index`","0..n","New variables created by this command." "IDVariables",":doc:`/composite-types/VariableReferenceBase/index`","0..1","One or more variables identifying unique rows in the wide data." "DropVariables",":doc:`/composite-types/VariableReferenceBase/index`","0..1","Variables to be dropped from the new dataset." "KeepVariables",":doc:`/composite-types/VariableReferenceBase/index`","0..1","Variables to be kept in the new dataset." 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` * **ReshapeWide** Relationships ~~~~~~~~~~~~~ The following identified item types reference this type. .. container:: image |stub| .. |stub| image:: ../../images/ReshapeWide.svg ReshapeWide_Stata_Examples ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. raw:: html

Example 1:

reshape wide inc ue, i(region id) j(year)
    
   {"command": "ReshapeWide",
       "MakeItems": [
               "ReshapeItemDescription":
                   {"$type": "ReshapeItemDescription",
                   "SourceVariableName": "inc",
                   "Stub": "inc",
   				"IndexVariableName":"year",
                   "IndexValues": 
                   {"$type":"NumberRangeExpression",
                           "From": "80",
                           "To": "83",
                           "By": "1"}
                       },
               "ReshapeItemDescription":
                   {"$type": "ReshapeItemDescription",
                   "SourceVariableName": "ue",
                   "Stub": "ue",
                   "IndexValues": 
                   {"$type":"NumberRangeExpression",
                           "From": "80",
                           "To": "83",
                           "By": "1"}
                       }
               ],
       "IDVariables": [ 
                   {"$type": "VariableSymbolExpression","VariableName": "region"},
                   {"$type": "VariableSymbolExpression","VariableName": "id"}
                   ],
           }
   

Example 2:

Long format             
   Centre  MetricTable                 QMetric         Status        Records
   PX001   RawCombinedResidencyfile    Starts          legal           50
   PX001   RawCombinedResidencyfile    Starts          illegal         10
   PX001   RawCombinedResidencyfile    Transitions     legal           57
   PX001   RawCombinedResidencyfile    Transitions     illegal         3
   PX001   RawCombinedResidencyfile    Ends            legal           60
   PX001   RawCombinedResidencyfile    Ends            illegal         0
   PX001   RawCombinedResidencyfile    SexValues       legal           60
   PX001   RawCombinedResidencyfile    SexValues       illegal         0
   PX001   RawCombinedResidencyfile    DoBValues       legal           60
   PX001   RawCombinedResidencyfile    DoBValues       illegal         0
                   
   Wide format             
   Centre  MetricTable                 QMetric         Illegal     Legal
   PX001   RawCombinedResidencyfile    Starts          10          50
   PX001   RawCombinedResidencyfile    Transitions     3           57
   PX001   RawCombinedResidencyfile    Ends            0           60
   PX001   RawCombinedResidencyfile    SexValues       0           60
   PX001   RawCombinedResidencyfile    DoBValues       0           60
   

Stata: reshape wide records, i(Centre MetricTable QMetric) j(Status)

{"command":"ReshapeWide",
   	"MakeItems":[
   		"ReshapeItemDescription":
   		{"SourceVariableName":"Records",
   			"Stub":"",
   			"IndexVariableName":"Status",
   			"IndexValues":
   			{"$type":"StringListExpression",
   				"values":[ "illegal", "legal"]
   				}
   				}
   			],
   	"IDVariables":[
   		{"$type": "VariableSymbolExpression","VariableName":"Centre"},
   		{"$type": "VariableSymbolExpression","VariableName":"MetricTable"},
   		{"$type": "VariableSymbolExpression","VariableName":"QMetric"}
   		]
   	}