A Stata command for replication checks and a slight improvement on compare frames (cf).
Copy and paste the following line on your Stata prompt:
net install cfsave, from("https://raw.githubusercontent.com/DiegoCiccia/cfsave/main") replace
The publication of empirical studies often hinges on the replicability of the results. Sorting, merging and other procedures may affect the data generating process, to the point that figures and tables generated by the same do file differ across run of the several script. This (very simple) routine combines the save and cf (compare frames) Stata commands.
syntax varlist using/ [, saveopt(string) cfopt(string)]
The logic of this command is very simple:
- If the using dataset does not exist yet, it is saved in the specified directory (with the save options specified in saveopt()).
- If the using dataset already exists, the program compares the specified variables (or the whole dataset if _all is specified) with the copy already existing. If the comparison yields only perfect matches, the dataset is saved.
Run the following block twice to check the command functionalities.
clear
set obs 1000
forv i = 1/10 {
gen g`i' = uniform()
}
cfsave _all using "dataset1.dta", saveopt(replace) cfopt(all)
This is a beta version. Please report bugs in the Issues section. For any other information, contact me by e-mail: cicciadiego99@gmail.com