Stata 15 help for checksum

[D] checksum -- Calculate checksum of file

Syntax

checksum filename [, options]

set checksum {on|off} [, permanently]

options Description ------------------------------------------------------------------------- save save output to filename.sum; default is to display a report replace may overwrite filename.sum; use with save saving(filename2[, replace]) save output to filename2; alternative to save -------------------------------------------------------------------------

Description

checksum creates filename.sum files for later use by Stata when it reads files over a network. These optional files are used to reduce the chances of corrupted files going undetected. Whenever Stata reads file filename.suffix over a network, whether by use, net, update, etc., it also looks for filename.sum. If Stata finds that file, Stata reads it and uses its contents to verify that the first file was received without error. If there are errors, Stata informs the user that the file could not be read.

set checksum on tells Stata to verify that files downloaded over a network have been received without error.

set checksum off, which is the default, tells Stata to bypass the file verification.

Technical note

checksum calculates a CRC checksum following the POSIX 1003.2 specification and displays the file size in bytes. checksum produces the same results as the Unix cksum command. Comparing the checksum of the original file with the received file guarantees the integrity of the received file.

When comparing Stata's checksum results with those of Unix, do not confuse Unix's sum and cksum commands. Unix's cksum and Stata's checksum use a more robust algorithm than that used by Unix's sum. In some Unix operating systems, there is no cksum command, and the more robust algorithm is obtained by specifying an option with sum.

Options

save saves the output of the checksum command to the text file filename.sum. The default is to display a report but not create a file.

replace is for use with save; it permits Stata to overwrite an existing filename.sum file.

saving(filename2 [, replace]) is an alternative to save. It saves the output in the specified filename. You must supply a file extension if you want one, because none is assumed.

permanently specifies that, in addition to making the change right now, the checksum setting be remembered and become the default setting when you invoke Stata.

Examples

Setup . sysuse auto . save auto

Calculate checksum of file . checksum auto.dta Checksum for auto.dta = 2694850408, size = 6442

Calculate checksum of file and save output to auto.sum . checksum auto.dta, save

Display contents of auto.sum . type auto.sum 1 6442 2694850408

The first value is the version number (possibly used for future releases). The second number is the file's size in bytes. This can be used with the checksum value to ensure that the file transferred without corruption. The third number is the checksum value itself. It is possible for two different files to have the same checksum value, but it is very unlikely that two files with the same checksum value could have the same file size.

Stored results

checksum stores the following in r():

Scalars r(version) checksum version number r(filelen) length of file in bytes r(checksum) checksum value


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index