205 stata命令:post

post命令是一個(gè)數(shù)據(jù)整理法寶

These commands are utilities to assist Stata programmers in performing Monte Carlo-type experiments.

The command post and its companion commands postfile and postclose are
described in postfile as “utilities to assist Stata programmers in performing Monte Carlo type experiments”. That description understates their usefulness, as post is one of the most flexible ways to accumulate results and save them for later use in an external file.

There are five commands manipulate the new dataset without disturbing the data in memory.

  • postfile declares the variable names and the filename of a (new) Stata dataset where results will be saved.
  • post adds a new observation to the declared dataset.
  • postclose declares an end to the posting of observations. After postclose, the new dataset contains the posted results and may be loaded using use.
  • postutil dir lists all open postfiles.
  • postutil clear closes all open postfiles.
image.png

假設(shè)你是一名淘寶店主,現(xiàn)在有位顧客購買了手環(huán)、U盤和支架?,F(xiàn)在你需要填份清單隨快遞一并附上。

checklist是空白清單,str30 commodity number price str10 unit是對商品描述的格式規(guī)定,using "C:\Users\Van\Desktop\post命令\checklist.dta"是清單所在的位置

post checklist是顧客購買的商品明細(xì),我們把明細(xì)通過post填寫到清單上

postclose checklist表明清單填寫完畢

postfile checklist str30 commodity number price str10 unit ///
using "C:\Users\Van\Desktop\post命令\checklist.dta", replace

post checklist ("華為榮耀手環(huán)5") (1) (189) ("元")
post checklist ("愛國者U盤32g") (1) (30) ("元")
post checklist ("筆記本支架") (1) (49) ("元")

postclose checklist

use "C:\Users\Van\Desktop\post命令\checklist.dta"

注意post的使用是一組命令,而非一行命令

示例

clear
cd "C:\Users\Van\Desktop\post命令"

postfile hdle foreign rep78 mean using autoinfo.dta, replace

sysuse auto, clear

forvalues f = 0/1 {
    forvalues r = 1/5{
        summarize price if foreign == `f' & rep78 == `r', meanonly
        post hdle (`f') (`r') (r(mean))
    }
}

postclose hdle

use autoinfo, clear
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容