Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
auto.dta データを使用して、上位 X% の中央値で PRICE 変数をトップコーディングしたいと考えています。たとえば、X% は 3%、4% などになります。Stata でこれを行うにはどうすればよいですか?
あなたの質問に答えるにあたり、上記のすべての値、たとえば top を次のコードの10%値 say X( )に置き換えたいと想定しています。top 90%
10%
X
top 90%
サンプルコードは次のとおりです。
program topcode sysuse auto, clear pctile pct = price, nq(10) dis r(r9) gen newprice=price replace newprice=r(r9) if newprice>r(r9) end