楼主: lindawu204
2021 4

[数据管理求助] 分割时间格式 [推广有奖]

  • 0关注
  • 0粉丝

小学生

28%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
46 点
帖子
4
精华
0
在线时间
4 小时
注册时间
2013-1-11
最后登录
2017-8-5

楼主
lindawu204 发表于 2014-8-14 15:36:59 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
我现在有时间变量fpeyq,是写年份和季度的,比如2001_1, 是2001年第一季度。
现在希望新建一个变量year, 把季度去掉,也就是说只留下2001, 2002, 2003这样的信息。
请问怎么写命令,谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:year 第一季度 时间变量 一季度 第一季 新建 信息

沙发
crystal8832 学生认证  发表于 2014-8-14 15:42:07
Title
[M5]
substr( ) — Extract substring
Syntax
string matrix substr(string matrix s, real matrix b, real matrix l)
string matrix substr(string matrix s, real matrix b)
Description
substr(s, b, l) returns the substring of s starting at position b and continuing for a length of l,
where
1. b specifies the starting position; the first character of the string is b = 1.
2. b > 0 is interpreted as distance from the start of the string; b = 2 means starting at the
second character.
3. b < 0 is interpreted as distance from the end of string; b = &#1048576;1 means starting at the last
character; b = &#1048576;2 means starting at the second from the last character.4. l specifies the length; l = 2 means for two characters.
5. l < 0 is treated the same as l = 0: no characters are copied.
6. l  . is interpreted to mean to the end of the string.
substr(s, b) is equivalent to substr(s, b, .) for strings that do not contain binary 0. If there
is a binary 0 to the right of b, the substring from b up to but not including the binary 0 is returned.
When arguments are not scalar, substr() returns element-by-element results.
Conformability
substr(s, b, l):
s: r1  c1
b: r2  c2
l: r3  c3; s, b, and l r-conformable
result: max(r1; r2; r3)  max(c1; c2; c3)
substr(s, b):
s: r1  c1
b: r2  c2; s and b r-conformable
result: max(r1; r2)  max(c1; c2)
Diagnostics

藤椅
lindawu204 发表于 2014-8-15 08:20:28
crystal8832 发表于 2014-8-14 15:42
Title
[M5]
substr( ) — Extract substring
版主版主。。。我看不懂哎。。。你这是STATA嘛?

板凳
crystal8832 学生认证  发表于 2014-8-15 08:39:03
lindawu204 发表于 2014-8-15 08:20
版主版主。。。我看不懂哎。。。你这是STATA嘛?
我给你发的是Stata的 文档里的。
help substr(s,b,l)

报纸
ermutuxia 发表于 2014-8-20 09:40:24
gen year=real(substr(fpeyq,1,4))

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-7 11:16