베팅이 이기면 'W', 패배면 'L'을 보여주는 다음 샘플 데이터에서 result라는 변수를 생성하고 있습니다.
이 변수를 각 사용자 이름에 대한 타임 스탬프별로 엄격한 순서로 행 단위로 연결하는 방법은 무엇입니까?
clear
input str16 username str40 betdate winnings
player1 "12NOV2008:19:04:01" -10
player1 "12NOV2008:12:03:44" 50
player2 "07NOV2008:14:03:33" -50
player2 "05NOV2008:09:00:00" -100
end
generate double timestamp=clock(betdate,"DMY hms")
format timestamp %tc
cap drop result
generate result = "L"
replace result = "W" if (winnings >0)
cap drop resulthistory
generate resulthistory = ""
replace resulthistory = concat(resulthisory + result), by(USERNAME timestamp)
독자들은 질문의 마지막 줄이 판타지 구문이라는 점에 유의해야합니다. 나머지는 작동합니다.
이것은 당신이 찾는 것일 수 있습니다. 데이터를 새로 읽을 때 변수 capture drop
는 존재할 수 없습니다.
clear
input str16 username str40 betdate winnings
player1 "12NOV2008:19:04:01" -10
player1 "12NOV2008:12:03:44" 50
player2 "07NOV2008:14:03:33" -50
player2 "05NOV2008:09:00:00" -100
end
gen double timestamp=clock(betdate,"DMY hms")
format timestamp %tc
gen result = cond(winnings > 0, "W", "L")
bysort username (timestamp): gen resulthistory = result[1]
by username : replace resulthistory = resulthistory[_n-1] + result if _n > 1
by username : replace resulthistory = resulthistory[_N]
list
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다