Stata连享会 主页 || 视频 || 推文 || 知乎 || Bilibili 站
温馨提示: 定期 清理浏览器缓存,可以获得最佳浏览体验。
New!
lianxh
命令发布了:
随时搜索推文、Stata 资源。安装:
. ssc install lianxh
详情参见帮助文件 (有惊喜):
. help lianxh
连享会新命令:cnssc
,ihelp
,rdbalance
,gitee
,installpkg
⛳ Stata 系列推文:
整理人:吴芳倩 (中国人民大学)
邮箱:wufangqian704@163.com
「Source: Help for dotemplate」
目录
屏幕前的你可曾经历过这样的尴尬场景?
如果你曾遇到一样的困扰,今天的推文请一定要收藏~~~ 绝对宝贝,绝对干货!
今天,我们将用几分钟的时间来学习 dotemplate
命令。
这是一款为我们的 do-file(和 ado-file) 预制模板 绘制模板的神奇命令。
从此以后,让最强 cp 组合——dotemplate
和 do-file(ado-file)携手为你打造最整洁和便捷的 code 编写吧!
我们固然可以直接执行如下命令直接安装程序文件:
. ssc install dotemplate // 安装 dotemplate
但作为长期受益于连享会的众多铁粉中的一员,我们怎能不知 cnssc
呢?!(cnssc-外部命令从此极速下载)
下面我们一起用 cnssc
体验 dotemplate
的飞速下载吧!
. ssc install cnssc // 安装 cnssc
. cnssc install dotemplate // 安装 dotemplate
完成安装后,输入 help dotemplate
即可查看 dotemplate
命令的帮助文件。
第一步,在 Stata 的命令窗口输入 dotemplate
,然后 enter 一下。Stata 会自动弹出如下对话框:
各选项的含义如下:
File information
File ext
:选择是要建立 do-file 还是 ado-file;Style
:选择 file 的类型,是 basic(简化版)还是 complete(完整版);File name
:必填项!!!你所建立的 do-file 或 ado-file 的文件名;Objective
:对 file 用途的描述;# Sections
:设置 file 的一级标题个数;# Subsections
:设置 file 的二级标题个数;Directory path
:设置 file 的存储路径。若不填,系统默认存储在 Stata 当前工作路径下。Author information
:
Author
:作者姓名;e-mail
:作者邮箱;Affiliation
:作者所在单位;url link
:作者个人主页地址。Additional options
:
Create log file
:选择是否为你的 do-file 建立一个同名的 log 文件;replace
:是否自动覆盖已有的重名 do-file。第二步,建立模板。 下面以 do-file 为例,分别建立 basic 和 complete 两种风格的模板。ado-file 同理。
(1)Basic(简化版)
简化版的选项选择示例如下图。由于简化版只有一个 section,故 Section 和 Subsection 项均无需填写。
下面是创建的简化版 do-file 模板。可以发现,其特点是只有一个 section。接下来,你可在 0:Program set up 下自由编写你的 code 啦!
/*==================================================
project: a basic dofile
Author: ZHANG San
----------------------------------------------------
Creation Date: 20 Jul 2021 - 11:09:12
==================================================*/
/*==================================================
0: Program set up
==================================================*/
exit
/* End of do-file */
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
(2)Complete(完整版)
完整版的选项选择示例如下图。我们设置 3 个一级标题,各一级标题下分别对应 2 个二级标题。
下面是创建的完整版 do-file 模板。可以发现,其条理非常清晰,非常易于自己和他人查找。接下来,你可在各一级和二级标题下开启你的 code 之旅啦!
/*==================================================
project: a complete dofile
Author: ZHANG San
E-email: xxxxxx@163.com
url: https://xxxx.edu.cn
Dependencies: xx University
----------------------------------------------------
Creation Date: 20 Jul 2021 - 13:08:46
Modification Date:
Do-file version: 01
References:
Output:
==================================================*/
/*==================================================
0: Program set up
==================================================*/
version 16 // 无论今后 Stata 更新到什么版本,我们当下用 Stata 16 写的命令都能被兼容
drop _all // 删掉数据库中所有变量和数据
/*==================================================
1:
==================================================*/
*----------1.1:
*----------1.2:
/*==================================================
2:
==================================================*/
*----------2.1:
*----------2.2:
/*==================================================
3:
==================================================*/
*----------3.1:
*----------3.2:
exit
/* End of do-file */
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
Notes:
1.
2.
3.
Version Control:
除了在对话框中逐项填入信息,我们也可以用命令行方式定义模板,一边反复利用和分享:
dotemplate, project("Program to create Templates for do-file") ///
file(detemplate) ///
author(Andres Castaneda) ///
path("C:\data\personal") ///
type(basic)
dotemplate, project("Program to create Templates for do-file") ///
file(detemplate) ///
author(Andres Castaneda) ///
path("C:\data\personal") ///
depend(The World Bank-LCSPP) ///
output(dotemplate.ado) ///
sections(2) ///
steps(2) ///
log
如果想拥有独特精美的 do-file,今天的宝贝建议和连享会下列宝贝搭配食用,效果更佳哦!
Note:产生如下推文列表的 Stata 命令为:
lianxh dofile
安装最新版lianxh
命令:
ssc install lianxh, replace
免费公开课
最新课程-直播课
专题 | 嘉宾 | 直播/回看视频 |
---|---|---|
⭐ 最新专题 | 文本分析、机器学习、效率专题、生存分析等 | |
研究设计 | 连玉君 | 我的特斯拉-实证研究设计,-幻灯片- |
面板模型 | 连玉君 | 动态面板模型,-幻灯片- |
面板模型 | 连玉君 | 直击面板数据模型 [免费公开课,2小时] |
⛳ 课程主页
⛳ 课程主页
关于我们
课程, 直播, 视频, 客服, 模型设定, 研究设计, stata, plus, 绘图, 编程, 面板, 论文重现, 可视化, RDD, DID, PSM, 合成控制法
等
连享会小程序:扫一扫,看推文,看视频……
扫码加入连享会微信群,提问交流更方便
✏ 连享会-常见问题解答:
✨ https://gitee.com/lianxh/Course/wikis
New!
lianxh
命令发布了:
随时搜索连享会推文、Stata 资源,安装命令如下:
. ssc install lianxh
使用详情参见帮助文件 (有惊喜):
. help lianxh