stata小小白

205 stata命令:post

2019-10-09  本文已影响0人  凡有言说

post命令是一个数据整理法宝

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.

image.png

假设你是一名淘宝店主,现在有位顾客购买了手环、U盘和支架。现在你需要填份清单随快递一并附上。

checklist是空白清单,str30 commodity number price str10 unit是对商品描述的格式规定,using "C:\Users\Van\Desktop\post命令\checklist.dta"是清单所在的位置

post checklist是顾客购买的商品明细,我们把明细通过post填写到清单上

postclose checklist表明清单填写完毕

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

post checklist ("华为荣耀手环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
上一篇 下一篇

猜你喜欢

热点阅读