【Stata】1- 基础命令

简介: 【Stata】1- 基础命令

一、调整变量格式:

format x1 %10.3f ——将 x1 的列宽固定为 10,小数点后取三位

format x1 %10.3g——将 x1 的列宽固定为 10,有效数字取三位

format x1 %10.3e ——将 x1 的列宽固定为 10,采用科学计数法

format x1 %10.3fc ——将 x1 的列宽固定为 10,小数点后取三位,加入千分位分隔符

format x1 %10.3gc ——将 x1 的列宽固定为 10,有效数字取三位,加入千分位分隔符

format x1 %-10.3gc ——将 x1 的列宽固定为 10,有效数字取三位,加入千分位分隔符,加入“-”表示左对

二、合并数据:

use "C:\Documents and Settings\xks\桌面\2006.dta", clear

merge using "C:\Documents and Settings\xks\桌面\1999.dta"

——将 1999 和 2006 的数据按照样本(observation)排列的自然顺序合并起来

use "C:\Documents and Settings\xks\桌面\2006.dta", clear

merge id using "C:\Documents and Settings\xks\桌面\1999.dta" ,unique sort

——将 1999 和 2006 的数据按照唯一的(unique)变量 id 来合并,在合并时对 id 进行排序(sort)

建议采用第一种方法。

  • help使用

Description

summarize calculates and displays a variety of univariate summary statistics. If no varlist is specified, summary statistics are calculated for all

the variables in the dataset.

Examples

. sysuse auto
. summarize
. summarize mpg weight
. summarize mpg weight if foreign
. summarize mpg weight if foreign, detail
. summarize i.rep78

%NV8W1FT1K6~M}1@DCM1M~D.png

image.png


~V_{P(%VXM7NLRP)1}]$KJJ.png

image.png


G7O6~6{Y%KDU~VLPUUX3WY7.png

image.png


TP5BN2F}0I~]K9DML0`W(WO.png

image.png

三-进行四则运算

. di 5+9

. di 5-9

. di 5*9

. di 10/2

. di 10^2

. di exp(0)

. di ln(1)

. di sqrt(4)


OML35BV5RB_BK(53$UWU}O6.png

image.png

  • 需求帮助
  • help 帮助
  • search 网络寻求帮助
  • 进入某路径
  • cd // 设定内存
    • set memory 20m // 设置 STATA 的内存空间为 20m
  • 打开和保存数据
    • clear // 清空内存数据
    • use // 打开 STATA 格式的数据文件
    • save // 保存内存中的数据
  • 导入数据
    • input // 录入数据
    • edit // 编辑数据
    • infile // 导入数据
    • insheet // 导入数据
  • 重整数据
    • append // 将有相同结果的数据纵向拼接(观察值拼接)
    • merge // 将两个数据文件横向拼接
    • xpose // 数据转置
    • reshape
    • generate // 生成新的数据
    • egen // 生成新的数据
    • rename // 变量重命令
    • drop // 删除变量或观察值
    • keep // 保留变量或观察值
    • sort // 对观察值按从小到大顺序重新排列
    • encode // 数值型数据转换为字符型数据
    • decode // 字符型数据转换为数值型数据
    • order // 变量顺序的重新排列
    • by // 分类操作
  • 报告数据
    • describe // 总体展示数据情况
    • codebook // 展示数据库中的每个变量情况
    • list // 列示内存中的数据
    • count // 报告共有多少观察值
    • inspect // 报告变量的分布
    • table // 数据列表
    • tabulate // 联列表
  • 显示和保存输出结果
    • display // 显示计算结果
    • log // 将输出结果存放入结果文件
目录
打赏
0
1
1
0
19
分享
相关文章
crictl 常见的命令大全
crictl(Container Runtime Interface Command Line Interface)是一个命令行工具,用于与符合Kubernetes容器运行时接口(CRI)规范的容器运行时进行交互。它提供了一系列命令来查看和管理容器、镜像、Pod等资源。以下是crictl的一些常见命令及其功能概述: ### 1. 镜像管理 * **查看镜像**: - `crictl images`:列出所有镜像。 - `crictl images | grep <image-name>`:查看特定镜像。 * **拉取镜像**: - `crictl pull <image_na
2169 7
【Stata】stata学习入门
【Stata】stata学习入门
211 0
【Stata】2-命令语句
【Stata】2-命令语句
127 0
Linux常用命令速查表
Linux常用命令速查表
83 0
Linux常用命令 - history命令详解
Linux常用命令 - history命令详解
193 0
Linux常用命令 - history命令详解
《Linux命令行与shell脚本编程大全》第二十二章 gawk进阶
gawk是一门功能丰富的编程语言,你可以通过它所提供的各种特性来编写好几程序处理数据。  22.1 使用变量 gawk编程语言支持两种不同类型的变量: 内建变量和自定义变量   22.1.1 内建变量 gawk程序使用内建变量来引用程序数据里的一些特殊功能   1.字段和记录分隔符变量 数据字段变量:允许你使用美元符和字段在该记录中的位置值来引用记录对应的字段。
1045 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等