~dricottone/ado-personal

ref: 9c2e7acaeba0ce0eb93bdfc0d3f97a9c35a35059 ado-personal/strlongest.ado -rw-r--r-- 420 bytes
9c2e7aca — dricottone Formatting 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Dominic R, 7/1/2020

program strlongest
	syntax [varlist(string default=none)] [, id(varname)]
	
	if "`varlist'"=="" {
		quietly ds, has(type string)
		local varlist `r(varlist)'
	}
	
	foreach v of varlist `varlist' {
		display "Examining `v'..."

		quietly generate Length = ustrlen(`v')
		quietly generate Last10 = usubstr(`v', -10, .)
		gsort -Length
		list `id' Length Last10 in 1/3

		drop Length Last10
	}
end