From 6010d646c8b5119640a17ac632bb089c5f97e14d Mon Sep 17 00:00:00 2001 From: Todd Seidelmann <18294602+seidelma@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:19:23 -0400 Subject: [PATCH] Respect variable format specs when writing STATA Closes #312. --- src/bin/write/mod_readstat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bin/write/mod_readstat.c b/src/bin/write/mod_readstat.c index 3ae33e45..65e66f40 100644 --- a/src/bin/write/mod_readstat.c +++ b/src/bin/write/mod_readstat.c @@ -166,6 +166,7 @@ static int handle_variable(int index, readstat_variable_t *variable, readstat_type_t type = readstat_variable_get_type(variable); const char *name = readstat_variable_get_name(variable); const char *label = readstat_variable_get_label(variable); + const char *format = readstat_variable_get_format(variable); size_t storage_width = readstat_variable_get_storage_width(variable); int display_width = readstat_variable_get_display_width(variable); int missing_ranges_count = readstat_variable_get_missing_ranges_count(variable); @@ -180,6 +181,8 @@ static int handle_variable(int index, readstat_variable_t *variable, readstat_variable_set_label_set(new_variable, label_set); if (mod_ctx->is_sas7bdat) { readstat_variable_set_format(new_variable, val_labels); + } else if (mod_ctx->is_dta) { + readstat_variable_set_format(new_variable, format); } }