srcfind is a small Stata helper for finding variables by exact source-metadata characteristic values. It is designed to work with srctag, which writes source metadata into Stata variable characteristics.
Stata variable characteristics are useful for provenance, but searching them can be awkward. srcfind gives a simple strict-equality search:
. srcfind src_agency BEA
vars with char[src_agency] == "BEA" (n=3):
price
mpg
weightThis is stricter than broad substring matching because it checks one named characteristic only.
net install srcfind, from("https://raw.githubusercontent.com/ericabooth/srcfind-stata/master/") replace
which srcfind
help srcfindInstall the companion package the same way:
net install srctag, from("https://raw.githubusercontent.com/ericabooth/srctag-stata/master/") replacesrcfind <charname> <value> [, count list into(localname)]Options:
count: print only the number of matches.list: print the matching variables; this is the default.into(localname): store the matching varlist in a local macro.wildcard: treat the value as a Stata wildcard pattern.contains: match when the value appears anywhere within the characteristic.ignorecase: ignore capitalization.profile: print a concisesrctag showprofile card for every match.
Catalog distinct values:
srcfind values <charname> [, nolinks]srcfind tags prints a clickable list of all source tag names found in memory. Click a tag name to list its values.
srcfind values src_agency prints a clickable list of all agency tags found in the dataset. In Stata's Results window, click a value to run the matching srcfind command.
srcfind BEA searches across all source tag values and prints a clickable tag/value index. A row like src_agency = BEA links to srcfind src_agency BEA, profile, which prints profile cards for matching variables.
Returned results:
r(varlist): matching variables.r(N): number of matching variables.
clear all
set more off
sysuse auto, clear
* 1. Create source tags on a few auto.dta variables.
* These agency names are illustrative for testing the workflow.
srctag price mpg weight, ///
agency("BEA") dataset("auto_example") vintage("1978") category("economics")
srctag length turn displacement, ///
agency("FHWA") dataset("auto_example") vintage("1978") category("infrastructure")
* 2. Add custom source-profile tags. You are not limited to the standard fields.
srctag price mpg, key(src_confidence) value("high")
srctag weight, key(src_note) value("example custom note")
* 3. Show profile cards for specific variables.
srctag show price mpg
* 4. Find variables by exact tag value. In the Results window, variable names
* are clickable and open srctag profile cards.
srcfind src_agency BEA
* 5. Search using flexible modes.
srcfind src_agency B*, wildcard
srcfind src_category struct, contains
srcfind src_agency bea, ignorecase
* 6. Print profile cards for all matched variables.
srcfind src_agency BEA, profile
* 7. Browse the source tag catalog. In the Results window, click:
* - tag names from srcfind tags to list values
* - values from srcfind values to list/profile matching variables
srcfind tags
srcfind values src_agency
* 8. Search across all source tag values. This is the card-catalog entry point:
* srcfind BEA should show a clickable row like src_agency = BEA.
srcfind BEA
* 9. Reuse matched variables programmatically when needed.
srcfind src_agency BEA, into(beavars)
summarize `beavars'You usually do not need return list. srcfind prints matching variables, counts, tag catalogs, or profile cards directly. Stored results such as r(N) and r(varlist) are there for programmatic use.
No-match searches are not errors. For example, if no variable has src_agency == "Census_ACS", then srcfind src_agency Census_ACS prints (none) and suggests catalog commands to inspect valid tags.
Use srctag when building a dataset and srcfind when analyzing or auditing it:
srctag pop_2024, agency("Census_PEP") dataset("PEP_coest2024") ///
url("https://www.census.gov/programs-surveys/popest.html") ///
vintage("2024") category("demographics")
srcfind src_agency Census_PEPsrcfind.ado: Stata command.srcfind.sthlp: Stata help file.srcfind.pkg: Stata package manifest fornet install.stata.toc: net-install table of contents.README.md: GitHub-facing documentation.
Eric A. Booth, Sr Researcher, Texas2036.org (eric.a.booth@gmail.com).