Title

varck -- Check existence of variables in Stata memory dataset

Syntax

varck varlist , lang(cn | en | auto) detail table noisily

Description

varck checks whether specified variables exist in the dataset in memory.
It handles single or multiple variables, prints color-coded bilingual output
(Chinese / English), and is tailored for interactive data exploration in
accounting empirical research.

鼎园会计 (Dingyuan Accounting) developed this program under the principle:
Science for Good, Humanities as Norm (科学向善，人文规范).

Version History

1.0.2 (2026-06-21) — Bugfix release.

Fixed detail mode display where variables concatenated on one line
due to _continue across loop iterations.

Replaced %~60s centering with SMCL to avoid
encoding artifacts with Unicode text.

Fixed unbalanced braces in example do-file (missing } before else).

1.0.1 (2026-06-21) — Bugfix release.

Fixed motto display (r/111, r/198) caused by literal double-quote
characters in macro values. Fixed table mode parsing error (r/198).
Fixed unbalanced braces in example do-file. Improved macro handling.

1.0.0 (2026-06-21) — Initial release.

Options

lang(cn|en|auto) -- output language.
Default is auto, which detects Stata's locale.

detail -- show type, label, format, and non-missing count for each
existing variable.

table -- compact side-by-side table (variable | status | type).

noisily -- verbose mode with accounting-specific tips.

Remarks

varck fills a niche among Stata's variable-checking tools.
We compare it with official commands and community packages below.

Comparison with Stata Official Commands

confirm variable varname -- stops at the first missing variable
with error code 111. No cumulative summary. Programmatic, not interactive.

describe varlist -- errors if any variable is missing.
Cannot tell you which ones exist and which do not.

unab abbrev -- expands abbreviated names. Not designed for batch
checking or user-friendly reporting.

Key gaps: (1) halt on first error, no summary;
(2) no bilingual support; (3) no human-friendly formatting;
(4) no accounting-specific guidance.

Comparison with Third-Party Programs

isvar (NJC, 2005) -- separates a list into existing and
non-existing. Limitations: minimal output (just two printed lists),
English only, no detail/table modes, no summary counts, no guidance.

checkfor2 (Diallo and Hardouin, 2020) -- adds
missing-value analysis with tolerance. Limitations: English only,
heavyweight for simple existence checking, verbose output,
no accounting context.

ckvar (2007) -- full error-checking framework using
characteristics and validation rules. Limitations: complex setup,
designed for data validation not quick queries, English only.

Innovations and Highlights of varck

1. Bilingual Chinese/English. First variable-checking utility with full
bilingual output. Auto-detects Stata locale. Valuable for Chinese accounting
researchers working with domestic (CSMAR, Wind, CNRDS) and international
(CRSP, Compustat, IBES) data.

2. Human-Centered Output. Color-coded indicators (result for existing,
error for missing), visual symbols, clear summary counts, optional compact
table and verbose modes.

3. Accounting Research Orientation. Designed for the typical workflow:
merge datasets from multiple vendors, check key financial variables
(ROA, ROE, leverage, accruals, etc.), identify naming discrepancies.
Includes accounting-specific diagnostic tips.

4. Progressive Information. Three tiers: default (concise check plus
summary), table (side-by-side scan), detail (type, label,
format, non-missing N).

5. Rich Return Values. Eight r-class macros and scalars:
r(exist), r(notexist), r(n_total), r(n_exist),
r(n_notexist), r(all_exist), r(any_exist),
plus isvar-compatible r(varlist) and r(badlist).

6. Non-Disruptive. Unlike confirm, varck always completes with
a full report. Critical for interactive exploration.

7. Academic Identity. Branded by 鼎园会计 (Dingyuan Accounting)
with the motto: 科学向善，人文规范.

Stored Results

Macros:

r(exist) -- existing variables (space-separated)

r(notexist) -- non-existing variables (space-separated)

r(varlist) -- same as r(exist); isvar-compatible

r(badlist) -- same as r(notexist); isvar-compatible

Scalars:

r(n_total) -- total variables queried

r(n_exist) -- number of existing variables

r(n_notexist) -- number of non-existing variables

r(all_exist) -- 1 if all exist, 0 otherwise

r(any_exist) -- 1 if at least one exists, 0 otherwise

Examples

Basic check:

. varck price mpg turn displacement

Chinese output:

. varck price mpg turn, lang(cn)

Table mode for many variables:

. varck roa roe lev size bm tobinq accrual, table

Detailed metadata:

. varck _all_variables, detail

Verbose with accounting tips:

. varck stkcd year industry roa roe, noisily lang(cn)

Programmatic use:

. varck roa roe lev size bm

. if r(all_exist) {

. reg roa roe lev size bm

. else {

. di as error "Missing variables: " r(notexist)

. }

Acknowledgments

The development team extends our most sincere gratitude to
Professor Kit Baum for his humility, generosity, and erudite scholarship.
We deeply appreciate his timely and sustained support of
鼎园会计 (Dingyuan Accounting).

varck is also inspired by the Stata community's variable-checking utilities
(isvar, checkfor2, ckvar). We gratefully acknowledge
their contributions.

Authors

Wu Lianghai

School of Business, Anhui University of Technology (AHUT)

Ma'anshan, Anhui, China

agd2010@yeah.net

Yang Lu

Rugao City Finance Bureau, Jiangsu Province

Jiangsu, China

1026835594@qq.com

Hu Fangfang

Wanjiang University of Technology (WJUT)

Ma'anshan, Anhui, China

huff470@163.com

Chen Liwen

School of Business, Anhui University of Technology (AHUT)

Ma'anshan, Anhui, China

2184844526@qq.com

Wu Hanyan

School of Economics and Management, NUAA

Nanjing, Jiangsu, China

2325476320@qq.com

科学向善，人文规范 -- Science for Good, Humanities as Norm

Also See

isvar, checkfor2, ckvar, confirm,
describe, ds

varck 1.0.2 | 2026-06-21 | 鼎园会计 Dingyuan Accounting