Title

Quantitative Text Analysis (qta) -- ESG Disclosure Analysis Tool

Syntax

qta [, savestats(filename) esgdictionary(filename) sentdictionary(filename) replace method(method) language(language)]

Description

qta performs quantitative text analysis on ESG (Environmental, Social, and Governance)
disclosure reports. The command analyzes text content to measure the extent and
quality of ESG disclosure based on different text analysis methods and languages.

The command generates multiple ESG disclosure metrics including dimension-specific scores,
total disclosure score, disclosure quality index, diversity measure, and completeness indicator.

Version 4.4 introduces improved dictionary handling with language consistency checks and
better error handling.

Options

savestats(filename) saves firm-level ESG statistics to the specified file.
If no filename is provided or "1" is used, defaults to "ESG_statistics.dta".
Minimum abbreviation: save()

esgdictionary(filename) specifies an external ESG classification dictionary file
for custom keyword definitions. If not specified, the default built-in dictionary is used.
This option is used with kwf, cosine, and jaccard methods.
Minimum abbreviation: esgd()

sentdictionary(filename) specifies an external sentiment dictionary file
for sentiment analysis. If not specified, the default built-in sentiment dictionary is used.
This option is used with the sentiment method.
Minimum abbreviation: sentd()

replace specifies that the output file should be replaced if it already exists.
Minimum abbreviation: r

method(method) specifies the text analysis method to use. Available methods include:

kwf - Keyword frequency analysis (default)

cosine - Cosine similarity

jaccard - Jaccard similarity

sentiment - Sentiment analysis

complexity - Text complexity analysis

readability - Text readability analysis
Minimum abbreviation: m()

language(language) specifies the language of the text content. Available options:

cn - Chinese text analysis (default)

en - English text analysis
Minimum abbreviation: lang()

Text Analysis Methods

1. Keyword Frequency (KWF) Method:

Counts the frequency of ESG-related keywords in each dimension (Environmental, Social, Governance, General ESG).

Algorithm: Frequency counting with normalization by text length

Outputs: Raw frequency counts, coverage indicators, and composite scores.

2. Cosine Similarity Method:

Measures the cosine similarity between document vectors and reference ESG dictionary vectors.

Algorithm: cos(θ) = (A·B) / (||A|| × ||B||)

Outputs: Similarity scores (0-1 range) for each dimension and overall.

3. Jaccard Similarity Method:

Calculates Jaccard coefficient based on the presence/absence of ESG keywords.

Algorithm: J(A,B) = |A∩B| / |A∪B|

Outputs: Set similarity scores (0-1 range) for ESG keyword coverage.

4. Sentiment Analysis Method:

Analyzes emotional tone using positive/negative sentiment dictionaries.

Algorithm: Sentiment = (Positive - Negative) / Total Words

Outputs: Normalized sentiment scores (0-1 range).

5. Text Complexity Method:

Measures linguistic complexity through lexical diversity and structural features.

Chinese: Sentence length, character diversity

English: Sentence length, word length, lexical density

Outputs: Composite complexity index (0-1 range).

6. Readability Method:

Assesses text readability using language-specific formulas.

Chinese: Adapted Flesch formula for Chinese text

English: Flesch Reading Ease Score

Outputs: Normalized readability scores (0-1 range, higher = more readable).

Dictionary Support

ESG Classification Dictionaries: Used with kwf, cosine, and jaccard methods

Format: Text file with four sections marked by headers: Environmental, Social, Governance, General_ESG

Example:
Environmental
环保
环境
排放
...
Social
员工
雇员
...

Sentiment Dictionaries: Used with sentiment method

Format: Text file with one word per line, followed by comma and sentiment score (1 for positive, -1 or -0.5 for negative)

Example:
积极,1
重视,1
优秀,1
问题,-1
不足,-1

Required Variables

year - Year of observation

stkcd - Stock code identifier

ESGreport - Text content of ESG/sustainability reports

Generated Variables

esg_environmental_score - Environmental dimension score

esg_social_score - Social dimension score

esg_governance_score - Governance dimension score

esg_general_esg_score - General ESG topic score

esg_total_score - Total ESG disclosure score

esg_disclosure_quality - Quality index

esg_diversity - Diversity measure across dimensions

esg_completeness - Completeness percentage across dimensions

Method-Specific Variables

esg_cosine_similarity - Cosine similarity score (cosine method)

esg_jaccard_similarity - Jaccard similarity score (jaccard method)

Default Dictionaries

The command includes comprehensive built-in dictionaries for both Chinese and English:

Chinese ESG Dictionary: Includes 60+ terms across Environmental, Social, Governance, and General_ESG categories.

English ESG Dictionary: Includes 60+ terms across Environmental, Social, Governance, and General_ESG categories.

Chinese Sentiment Dictionary: Includes 30 positive words and 18 negative words with sentiment scores.

English Sentiment Dictionary: Includes 30 positive words and 17 negative words with sentiment scores.

Important Notes

Language Consistency: Ensure that the dictionary language matches the text content language.
Using Chinese dictionaries with English text (or vice versa) will result in poor matching.

Dictionary Format: External dictionaries must follow the specified format exactly.
ESG dictionaries use category headers, sentiment dictionaries use comma-separated scores.

Examples

Basic analysis with default Chinese dictionary:

. qta

Analysis with English language:

. qta, lang(en)

Keyword frequency analysis with custom ESG dictionary:

. qta, esgdictionary(esg_dict_cn.txt)

Cosine similarity analysis:

. qta, method(cosine)

Jaccard similarity analysis:

. qta, method(jaccard)

Sentiment analysis with custom sentiment dictionary:

. qta, method(sentiment) sentdictionary(sentiment_cn.txt)

Text complexity analysis:

. qta, method(complexity)

Readability analysis:

. qta, method(readability)

Analysis with both custom dictionaries:

. qta, esgdictionary(esg_dict_en.txt) sentdictionary(sentiment_en.txt) lang(en)

Analysis with custom dictionary and saving statistics:

. qta, savestats(my_esg_stats.dta) esgdictionary(my_esg_dict.txt) replace

Using minimum abbreviations:

. qta, save(1) esgd(esg_dict.txt) sentd(sentiment.txt) r m(cosine) lang(en)

Authors

Wu Lianghai

School of Business, Anhui University of Technology (AHUT)

Ma'anshan, China

E-mail: agd2010@yeah.net

Chen Liwen

School of Business, Anhui University of Technology (AHUT)

Ma'anshan, China

E-mail: 2184844526@qq.com

Wu Hanyan

School of Economics and Management, Nanjing University of Aeronautics and Astronautics (NUAA)

Nanjing, China

E-mail: 2325476320@qq.com

Shen Yongxu

School of Business, Anhui University of Technology (AHUT)

Ma'anshan, China

E-mail: 3010760031@qq.com

Version

Version 4.4 - 27Oct2025

Also See

See text analysis for related text analysis commands in Stata.