/* parqit summarize - Summary statistics, tables, correlations, and histograms *! VERSION 0.1.37 07sep2026 User > parqit > Summary statistics, tables, and correlations... Launch directly with: db parqit_stats (menu installed by: parqit menu) Every statistic is computed by the engine as a push-down query over the current view; only the summary numbers (or the histogram bin table) reach Stata, and the data in memory are unchanged. */ VERSION 16.0 INCLUDE _std_wide DEFINE _dlght 410 INCLUDE header HELP hlp1, view("help parqit##explore") RESET res1 SCRIPT PREINIT BEGIN create STRING dlgname dlgname.storeDialogClassName create DOUBLE pq_populate_error END PROGRAM POSTINIT_PROGRAM BEGIN call program main_mode call program main_context END DIALOG main, label("parqit summarize - Summary statistics, tables, correlations, and histograms") /// tabtitle("Main") BEGIN RADIO rb_sum _lft _top _lw80 ., /// first /// onclickon(program main_mode) /// label("Summary statistics (summarize)") BUTTON bu_pop _rj80 @ 80 ., /// onpush(program main_populate) /// tooltip("Populate the comboboxes with the variable names of the current view") /// label("Populate") COMBOBOX cb_sumvars _ilft _ss 380 ., /// append /// dropdown /// contents(numeric_list) /// label("Variables (leave empty for all numeric variables)") CHECKBOX ck_detail 410 @ 180 ., /// option(detail) /// label("Display additional statistics") RADIO rb_tab _lft _ls _iwd ., /// onclickon(program main_mode) /// label("One-way or two-way table of frequencies (tabulate)") TEXT tx_tab1 _ilft _ss 220 ., label("Row variable:") TEXT tx_tab2 300 @ 290 ., label("Column variable (optional):") COMBOBOX cb_tab _ilft _ss 260 ., /// dropdown /// contents(vv_list) /// error("Variables to tabulate") /// label("Row variable") COMBOBOX cb_tab2 300 @ 290 ., dropdown contents(vv_list) /// onselchange(program main_mode) label("Column variable (optional)") CHECKBOX ck_tmiss _ilft _ss 175 ., /// option(missing) /// label("Include missing values") CHECKBOX ck_trow 390 @ 95 ., /// option(row) /// label("Row percent") CHECKBOX ck_tcol 490 @ 100 ., /// option(col) /// label("Column percent") CHECKBOX ck_nolabel 210 @ 170 ., option(nolabel) label("Show codes (nolabel)") RADIO rb_ts _lft _ls _iwd ., /// onclickon(program main_mode) /// label("Compact table of chosen statistics (tabstat)") COMBOBOX cb_tsvars _ilft _ss 380 ., /// append /// dropdown /// contents(numeric_list) /// error("Variables") /// label("Variables") TEXT tx_tsby 410 @ 40 ., /// label("By:") right COMBOBOX cb_tsby 455 @ 135 ., /// dropdown /// contents(vv_list) /// option(by) /// label("Group statistics by variable") /// tooltip("Group summaries only, without an overall total; at most 200 nonmissing groups") CHECKBOX ck_s_n _ilft _ms 60 ., /// label("n") CHECKBOX ck_s_mean 85 @ 65 ., /// default(1) /// label("mean") CHECKBOX ck_s_sd 155 @ 55 ., /// default(1) /// label("sd") CHECKBOX ck_s_min 215 @ 55 ., /// label("min") CHECKBOX ck_s_max 275 @ 60 ., /// label("max") CHECKBOX ck_s_med 340 @ 75 ., /// label("median") CHECKBOX ck_s_sum 420 @ 60 ., /// label("sum") CHECKBOX ck_s_var 485 @ 55 ., /// label("var") TEXT tx_sextra _ilft _ms 260 ., /// label("Other statistics (range, p##; e.g., p90 range):") EDIT ed_sextra 290 @ 195 ., /// label("Other statistics") CHECKBOX ck_tsave 500 @ 90 ., /// option(save) /// label("Save in r()") /// tooltip("Return the computed tables as Stata matrices; no data file is written") RADIO rb_corr _lft _ls _iwd ., /// onclickon(program main_mode) /// label("Correlations, listwise (correlate) or pairwise (pwcorr)") COMBOBOX cb_corr _ilft _ss 260 ., /// append /// dropdown /// contents(numeric_list) /// error("Variables") /// label("Variables") CHECKBOX ck_pw 300 @ 90 ., /// onclickon(program main_mode) /// onclickoff(program main_mode) /// label("Pairwise") CHECKBOX ck_obs 395 @ 95 ., /// option(obs) /// label("Number of obs") CHECKBOX ck_sig 490 @ 100 ., /// option(sig) /// label("Significance") RADIO rb_hist _lft _ls _iwd ., /// last /// onclickon(program main_mode) /// label("Histogram with engine-computed bins (histogram)") COMBOBOX cb_hvar _ilft _ss 200 ., /// dropdown /// contents(numeric_list) /// error("Variable") /// label("Variable") TEXT tx_bins 230 @ 50 ., /// label("Bins:") right EDIT ed_bins 285 @ 60 ., /// numonly /// option(bins) /// label("Number of bins") /// tooltip("Empty or 0: automatic; positive integer requests capped at 1000 bins") CHECKBOX ck_nodraw 360 @ 230 ., /// option(nodraw) /// label("Do not draw the histogram") TEXT tx_context _lft 365 470 ., label("Current view: refresh to check") BUTTON bu_context _rj80 @ 80 ., label("Refresh") onpush(program main_populate) END LIST vv_list BEGIN END LIST numeric_list BEGIN END PROGRAM main_mode BEGIN call main.cb_sumvars.disable call main.ck_detail.disable call main.cb_tab.disable call main.cb_tab2.disable call main.tx_tab1.disable call main.tx_tab2.disable call main.ck_nolabel.disable call main.ck_tmiss.disable call main.ck_trow.disable call main.ck_tcol.disable call main.cb_tsvars.disable call main.tx_tsby.disable call main.cb_tsby.disable call main.ck_s_n.disable call main.ck_s_mean.disable call main.ck_s_sd.disable call main.ck_s_min.disable call main.ck_s_max.disable call main.ck_s_med.disable call main.ck_s_sum.disable call main.ck_s_var.disable call main.tx_sextra.disable call main.ed_sextra.disable call main.ck_tsave.disable call main.cb_corr.disable call main.ck_pw.disable call main.ck_obs.disable call main.ck_sig.disable call main.cb_hvar.disable call main.tx_bins.disable call main.ed_bins.disable call main.ck_nodraw.disable if main.rb_sum { call main.cb_sumvars.enable call main.ck_detail.enable } if main.rb_tab { call main.cb_tab.enable call main.cb_tab2.enable call main.tx_tab1.enable call main.tx_tab2.enable call main.ck_nolabel.enable call main.ck_tmiss.enable if main.cb_tab2 { call main.ck_trow.enable call main.ck_tcol.enable } } if main.rb_ts { call main.cb_tsvars.enable call main.tx_tsby.enable call main.cb_tsby.enable call main.ck_s_n.enable call main.ck_s_mean.enable call main.ck_s_sd.enable call main.ck_s_min.enable call main.ck_s_max.enable call main.ck_s_med.enable call main.ck_s_sum.enable call main.ck_s_var.enable call main.tx_sextra.enable call main.ed_sextra.enable call main.ck_tsave.enable } if main.rb_corr { call main.cb_corr.enable call main.ck_pw.enable if main.ck_pw { call main.ck_obs.enable call main.ck_sig.enable } } if main.rb_hist { call main.cb_hvar.enable call main.tx_bins.enable call main.ed_bins.enable call main.ck_nodraw.enable } END PROGRAM main_populate BEGIN call program main_context call pq_populate_error.setvalue 0 put "parqit _dlgvars " put dlgname put " vv_list, numeric(numeric_list)" stata hidden immediate if pq_populate_error { stopbox stop "Unable to get the variable names of the current view." /// "Open a view first (User > parqit > Read data...)." } call main.cb_sumvars.repopulate call main.cb_tab.repopulate call main.cb_tab2.repopulate call main.cb_tsvars.repopulate call main.cb_tsby.repopulate call main.cb_corr.repopulate call main.cb_hvar.repopulate END PROGRAM main_context BEGIN put "parqit _dlgcontext " put dlgname stata hidden queue clear END PROGRAM command BEGIN if main.rb_sum { put "parqit summarize" if main.cb_sumvars { put " " main.cb_sumvars } beginoptions option main.ck_detail endoptions } if main.rb_tab { require main.cb_tab if main.cb_tab.isWordCountGT(1) | main.cb_tab2.isWordCountGT(1) { stopbox stop "Enter one variable in each tabulation field." } put "parqit tabulate " main.cb_tab if main.cb_tab2 { put " " main.cb_tab2 } beginoptions option main.ck_tmiss option main.ck_nolabel if main.cb_tab2 { option main.ck_trow option main.ck_tcol } endoptions } if main.rb_ts { require main.cb_tsvars put "parqit tabstat " main.cb_tsvars beginoptions if main.ck_s_n | main.ck_s_mean | main.ck_s_sd | /// main.ck_s_min | main.ck_s_max | main.ck_s_med | /// main.ck_s_sum | main.ck_s_var | main.ed_sextra { put "statistics(" if main.ck_s_n { put "n " } if main.ck_s_mean { put "mean " } if main.ck_s_sd { put "sd " } if main.ck_s_min { put "min " } if main.ck_s_max { put "max " } if main.ck_s_med { put "median " } if main.ck_s_sum { put "sum " } if main.ck_s_var { put "var " } if main.ed_sextra { put main.ed_sextra } put ") " } optionarg main.cb_tsby option main.ck_tsave endoptions } if main.rb_corr { require main.cb_corr if main.ck_pw { put "parqit pwcorr " main.cb_corr beginoptions option main.ck_obs option main.ck_sig endoptions } else { put "parqit correlate " main.cb_corr } } if main.rb_hist { require main.cb_hvar put "parqit histogram " main.cb_hvar beginoptions optionarg main.ed_bins option main.ck_nodraw endoptions } END