Recently I was running some reliable code on another computer that I don't use frequently, and I was hitting an error. After some troubleshooting I found that the command -isid- was behaving differently across the two computers, which I assume it has to do with the Stata version. This short program, run on both computers, illustrates the behavior:
This is the output when I run -test_isid- on my everyday computer (version 16.0):
version 16.0
(1978 Automobile Data)
variable make was str18 now str29
(1 real change made)
74
74
n1==n2 in 74 of 74 observations
This is the output when I run -test_isid- on my other computer (version 16.1):
version 16.1
(1978 Automobile Data)
variable make was str18 now str29
(1 real change made)
74
0
n1==n2 in 0 of 74 observations
I didn't expect that -isid- would ever sort data ... Is this intended behavior? It seems as if the data get sorted by the string variable that is in the -isid- varlist (with the trailing spaces thrown to the bottom of the data set). If I use -gisid- instead of -isid- then there is no sorting. After updating to 16.1 on my everyday computer, it also displays this sorting behavior.
Code:
cap program drop test_isid
program test_isid
noi version
sysuse auto, clear
keep make
sort make
replace make = "string with a trailing space " in 1
gen n1 = _n
isid make
*gisid make
gen n2 = _n
count
loc N = `r(N)'
count if n1==n2
noi di "n1==n2 in `r(N)' of `N' observations"
list * if _n<=5
end
test_isid
version 16.0
(1978 Automobile Data)
variable make was str18 now str29
(1 real change made)
74
74
n1==n2 in 74 of 74 observations
This is the output when I run -test_isid- on my other computer (version 16.1):
version 16.1
(1978 Automobile Data)
variable make was str18 now str29
(1 real change made)
74
0
n1==n2 in 0 of 74 observations
I didn't expect that -isid- would ever sort data ... Is this intended behavior? It seems as if the data get sorted by the string variable that is in the -isid- varlist (with the trailing spaces thrown to the bottom of the data set). If I use -gisid- instead of -isid- then there is no sorting. After updating to 16.1 on my everyday computer, it also displays this sorting behavior.

Comment