June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,22 @@
program define maprange
version 15.1
syntax varname(numeric) [if] [in], ///
from(numlist min=2 max=2) to(numlist min=2 max=2) ///
GENerate(name) [REPLACE]
tempname a b c d h
sca `a'=`:word 1 of `from''
sca `b'=`:word 2 of `from''
sca `c'=`:word 1 of `to''
sca `d'=`:word 2 of `to''
sca `h'=(`d'-`c')/(`b'-`a')
cap confirm variable `generate'
if "`replace'"=="replace" & !_rc {
qui replace `generate'=(`varlist'-`a')*`h'+`c' `if' `in'
}
else {
if "`replace'"=="replace" {
di in gr `"(note: variable `generate' not found)"'
}
qui gen `generate'=(`varlist'-`a')*`h'+`c' `if' `in'
}
end

View file

@ -0,0 +1,6 @@
clear
set obs 11
gen x=_n-1
maprange x if mod(x,2)==0, gen(y) from(0 10) to(-10 10)
maprange x if mod(x,2)!=0, gen(y) from(0 10) to(-100 100) replace
list