여러 번, 나는 그것이 만들어지지 않았 음을 알기 위해서만 매크로를 정의하려고 시도합니다.Stata 로컬 매크로가 정의되지 않았습니다.
나의 첫번째 질문은 수동으로 내가 시도하는 모든 단일 의심스러운
local mylocal ...
정의 후macro list
를 입력하는 것보다 이러한 실패를 추적 할 수있는 더 좋은 방법은 무엇입니까?두 번째 이유는 로컬 정의가 자동으로 실패하는 이유는 무엇입니까? 이 이벤트에 대한 경고를 활성화하는 방법이 있습니까?
세 번째로 아래 코드는 가장 최근에이 문제가 나를 좌절 시켰던 부분을 보여줍니다. 문자열 벡터에서 단어의 위치를 파악합니다. 위치를 하나씩 감소시키는 단계; 해당 (직전) 위치에서 단어를 움켜 잡습니다. 모든 포인터를 환영 할 것입니다.
.
local cuts 0 15 32 50
local mycut 32
local myposn : list posof "`mycut'" in cuts
// two methods that fail loudly:
local mynewcut : word ``myposn'-1' of cuts
local mynewcut : word `myposn'-1 of cuts
// five methods that fail silently, creating nothing:
local mynewcut : word `=`myposn'-1' of cuts // 1
scalar tmp = `myposn'
local mynewcut : word `=tmp-1' of cuts // 2
scalar tmp2 = tmp -1 // 3
local mynewcut : word `=tmp2' of cuts
local mynewposn = `=`myposn'-1'
local mynewcut : word `mynewposn' of cuts // 4
local mynewcut : word `=`mynewposn'' of cuts // 5
// also fails silently (and is not what I'm looking for):
local mysamecut : word `myposn' of cuts
Ah, duh, 내 매크로 변수 "cuts"에 대해 따옴표를 잊어 버렸습니다. 이러한 침묵 실패를 모니터링하는 데 도움이 될만한 조언이 있습니까? – Frank
감사합니다. 나는'display' 또는'assert'를 사용하는 습관을 갖습니다. (개념적으로) 간단한 점검을 위해 많은 인용 부호가 필요하기 때문에 너무 나쁘다. Stata가'word # of '다음에 오는 모든 것을 어떻게 파싱하는지 흥미 롭습니다. – Frank
"견적 문제"로 인해 물린 횟수를 잊어 버렸습니다. –