Skip to content

Commit 86f8df1

Browse files
committed
Execute sas_from_r safely
1 parent 87d6f9b commit 86f8df1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

R/from-r.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@ sas_from_r <- function(
5252
date_dict <- from_r_datedict(x)
5353
factor_dict <- reticulate::dict()
5454
if (!factors_as_strings) {
55-
from_r_factordict(x, libref)
55+
factor_dict <- from_r_factordict(x, libref)
5656
}
5757

58-
.sas_from_r(x_data, table_name, libref, date_dict, factor_dict)
58+
execute_if_connection_active(
59+
reticulate::py_capture_output(
60+
.sas_from_r(x_data, table_name, libref, date_dict, factor_dict)
61+
)
62+
)
5963

6064
invisible(x)
6165
}
@@ -126,7 +130,11 @@ from_r_factordict <- function(x, libref) {
126130

127131
format_statements <- paste0(format_dataframe$statement, collapse = "\n\n")
128132

129-
.sas_run_string(format_statements)
133+
execute_if_connection_active(
134+
reticulate::py_capture_output(
135+
.sas_run_string(format_statements)
136+
)
137+
)
130138

131139
reticulate::py_dict(
132140
factor_col_names,

0 commit comments

Comments
 (0)