Skip to contents

Renders the file's markup to plain text (see .smcl_render()), splits it into one chunk per Stata command (the {com}. <command> echo, mirroring read_r_output()'s R-console-echo splitting), and extracts each chunk's result tables and one-line statistics. graph export "....png" commands are recovered as ordinary command text; the PNG itself is never embedded in a .smcl file (Stata writes it to disk separately), so no chart data exists in this format to extract (see the file header).

Usage

import_stata_smcl(path)

Arguments

path

path to a .smcl file

Value

a list of result tables, each list(analysis, title, data, syntax, table_index) – the same shape read_stat_tables() returns for .jasp/.omv/.spv, so all four formats can be processed identically downstream. analysis is the Stata command that produced the table (e.g. "summarize communication_index barrier_index"); syntax duplicates analysis (Stata's own echoed command IS its syntax, unlike .spv where syntax is recovered separately from a different structure). Empty list if the file has no recoverable command output.

Examples

smcl <- tempfile(fileext = ".smcl")
writeLines(c("{smcl}", "{com}. summarize congruent incongruent", "",
  "{txt}    Variable {c |}        Obs        Mean    Std. dev.       Min        Max",
  "{hline 13}{c +}{hline 57}",
  "{space 3}congruent {c |}{res}        131    15.10411    4.118164      8.63     27.226",
  "{txt}{space 1}incongruent {c |}{res}        131    23.00398    4.783391    13.556     38.891",
  "{txt}"), smcl)
tables <- import_stata_smcl(smcl)
tables[[1]]$data
#>      Variable | Obs     Mean Std. dev.    Min    Max
#> 1   congruent | 131 15.10411  4.118164   8.63 27.226
#> 2 incongruent | 131 23.00398  4.783391 13.556 38.891