data_prepare
Convert CSV, Excel, SPSS, Stata, or Parquet data into an Mplus .dat file with missing values flagged. Get ready-to-paste DATA and VARIABLE blocks plus a summary of renamed or recoded variables.
Instructions
Convert a CSV, Excel, SPSS (.sav), Stata (.dta) or parquet file into an Mplus .dat file: numeric only, no header, missing values flagged, names cut to 8 characters. Returns the DATA and VARIABLE block to paste into an input file, plus a per-variable summary and a note of anything that was renamed or recoded.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sep | No | Field separator for text files, e.g. ';'. | |
| path | Yes | Source data file. `~` is expanded. | |
| sheet | No | Excel sheet name. Default: the first sheet. | |
| header | No | Whether row 1 holds column names. | |
| decimals | No | Decimal places for non-integer columns. | |
| encoding | No | Encoding of a text file, e.g. utf-8, big5. | utf-8 |
| out_path | No | Where to write the .dat file. Defaults to the source name with .dat. | |
| variables | No | Columns to keep, in this order. Default: all of them. | |
| na_strings | No | Extra strings to read as missing, e.g. ['NA', '99']. | |
| missing_flag | No | Number written for missing values. | |
| encode_strings | No | Turn text columns into numeric codes instead of dropping them. | |
| drop_incomplete | No | Listwise-delete incomplete cases. Rarely wanted - Mplus uses FIML. |