首页 > 其他分享 >STATA 字母 ABCDEF 转 123456

STATA 字母 ABCDEF 转 123456

时间:2023-05-13 22:55:17浏览次数:49  
标签:123456 var1 replace substr STATA tobytes ABCDEF gen

clear
input str10 var1
A
B
C
D
E
F
end
cap:ssc install sencode
save cishi1,replace
 encode var1,generate (var2) 
tostring var2,replace
gen var4=tobytes(var1)
gen var6=substr(tobytes(var1),3,.)
gen var8=char(real(substr(tobytes(var1),3,.))-16)

 

标签:123456,var1,replace,substr,STATA,tobytes,ABCDEF,gen
From: https://www.cnblogs.com/xkdn/p/17398429.html

相关文章

  • STATA joinby命令
    joinby。当我们进行数据的横向合并时,经常会用到merge命令,但是在使用merge命令进行一对一合并、一对多合并、多对一合并和多对多合并都不是我们想要的结果时,可以考虑使用joinby组内交叉合并。老规矩,还是先上命令语法和选项介绍。一、命令介绍1、命令语法 joinby[varlist]usin......
  • STATA traj插件应用
    usehttps://www.andrew.cmu.edu/user/bjones/traj/data/panss.dta,cleargenoos=0replaceoos=rbinomial(1,.2)traj,var(p1-p6)indep(t1-t6)model(cnorm)min(-999)max(999)order(331)risk(risper)dropout(111)dcov(risperrisperrisp......
  • STATA 按STKCD YEAR 合并所有的kamd
    uselinshi0510,clearbysstkcdyear:genbz=_nlocalk=_Nlocalaa""localbb""localdd""genbzz=""formatbzz%200sforvaluesi=1/`k'{localaa=stkcd[`i']localbb=year[`i']ifbz[`i&......
  • Stata与Python的交互使用
    官方参考文档https://www.stata.com/python/api17/index.html不论是从Stata里调用python,还是从python里调用stata,都无法实现stata和python的数据互通。为了实现stata和Python的数据互通,stata官方提供了名为sfi(StataFunctionInterface)的包,可以在python中获得stata的数据。先......
  • prometheus123456
    #catprometheus/prometheus-consul.ymlglobal:scrape_interval:15s#Setthescrapeintervaltoevery15seconds.Defaultisevery1minute.evaluation_interval:15s#Evaluaterulesevery15seconds.Th......
  • STATA 循环应用
    gentz=0localvvpid_a_c1pid_a_c2pid_a_c3pid_a_c4pid_a_c5pid_a_c6pid_a_c7pid_a_c8pid_a_c9pid_a_c10localk=_Nforvaluesi=1/`k'{localmm=0foreachvarofvarlist`vv'{localmm=`mm'+1ifpid[`i']==`var'[`i......
  • stata sfi.Data举例
    sysuseautopythonfromsfiimportDatadataraw=Data.get('foreign')datarawend//.python//-----------------------------------------------python(typeendtoexit)--------------------------------------------------------------------------......
  • python stata 交互
    pythonfromsfiimportDatafromsfiimportDatetimefromsfiimportFramefromsfiimportMacrofromsfiimportValueLabelcca="北京"ac=cca.split('')foriiinac:Macro.setLocal('x',ii)enddisp"`x'"py......
  • AtCoder ABC 299 ABCDEFG
    A-TreasureChest题意给定由\(\texttt{.}\)、\(\texttt{|}\)、\(\texttt{*}\)三种字符组成的长度为\(n\)的字符串\(s\),保证\(\texttt{|}\)的个数为\(2\),\(\texttt{*}\)的个数为\(1\)。判断\(\texttt{*}\)是否在两个\(\texttt{|}\)之间。代码#include<cstrin......
  • stata 程序写法 静态运行写法
    programmysum,rclasssyntaxvarnamereturnlocalvarname`varlist'tempvarnewquietly{countif!missing(`varlist')returnscalar......