楼主: fgkjvbk
3156 2

[数据管理求助] 求助!!请问stata如何统计数据类型是字符串的出现次数 [推广有奖]

  • 3关注
  • 0粉丝

本科生

98%

还不是VIP/贵宾

-

威望
0
论坛币
31 个
通用积分
3.9846
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
631 点
帖子
46
精华
0
在线时间
156 小时
注册时间
2020-12-23
最后登录
2024-4-16

楼主
fgkjvbk 学生认证  发表于 2021-4-15 19:58:42 |只看作者 |坛友微信交流群|倒序 |AI写论文
10论坛币
各位stata的大佬们好,我想对数据中JournalTitle中出现的字符串进行统计,请问要怎么操作,谢谢回答!
clear
input long aid int pubyear str239 journal_title float(d_value career_age N)
4670844 2000 "The American naturalist"                                                                                         -.0556622  9  6
227960 2000 "Angewandte Chemie (International ed. in English)"                                                                        0  9  6
3279037 2000 "Journal of veterinary cardiology : the official journal of the European Society of Veterinary Cardiology"                0  9  6
8453307 2000 "IEEE transactions on ultrasonics, ferroelectrics, and frequency control"                                                 0  9  6
8894826 2000 "IEEE transactions on image processing : a publication of the IEEE Signal Processing Society"                             0  9  6
4431279 2000 "The American naturalist"                                                                                          .0789474  9  6
527603 2000 "IEEE transactions on image processing : a publication of the IEEE Signal Processing Society"                      -.025641 10 17
3412062 2000 "IEEE transactions on image processing : a publication of the IEEE Signal Processing Society"                      -.012987 10 17
7351204 2000 "The American naturalist"                                                                                         -.0118483 10 17
1324929 2001 "Journal of evolutionary biology"                                                                                -.00499445 10 17
7777752 2001 "Journal of investigative medicine : the official publication of the American Federation for Clinical Research"  -.00144748 10 17
3472062 2001 "Calcified tissue international"                                                                                          0 10 17
4513185 2000 "Bioscience, biotechnology, and biochemistry"                                                                             0 10 17
1070450 2001 "Phytopathology"                                                                                                          0 10 17
5663726 2001 "Journal of health psychology"                                                                                            0 10 17
2608510 2001 "Journal of tropical pediatrics"                                                                                          0 10 17
6304401 2001 "Comparative and functional genomics"                                                                             .00172861 10 17
8096653 2001 "Mycorrhiza"                                                                                                       .0078125 10 17
4717488 2000 "Avian pathology : journal of the W.V.P.A"                                                                         .0163934 10 17
7188770 2000 "The American naturalist"                                                                                          .0632911 10 17
4452688 2001 "Angewandte Chemie (International ed. in English)"                                                                 .0987654 10 17
5598028 2001 "Oecologia"                                                                                                         .232877 10 17
9001194 2000 "Environmental management"                                                                                              .75 10 17
2373133 2002 "Oecologia"                                                                                                        -.133333 11 34
5203462 2002 "Oecologia"                                                                                                           -.072 11 34
4670844 2002 "Oecologia"                                                                                                       -.0615385 11 34
5203462 2002 "Oecologia"                                                                                                       -.0393701 11 34
4790330 2001 "The American naturalist"                                                                                          -.037037 11 34
8070924 2002 "Oecologia"                                                                        


最佳答案

DΘstinyじò 查看完整内容

统计journal_title变量每一类值的个数吗?
关键词:Stata 数据类型 统计数据 tata 字符串
沙发
DΘstinyじò 发表于 2021-4-15 19:58:43 |只看作者 |坛友微信交流群
统计journal_title变量每一类值的个数吗?
  1. bys journal_title : gen wanted = _N
复制代码

使用道具

public class StringTest3 {

    public static void main(String[] args) {
        //定义一个字符串
        String s = "Person1314Study";
        
         //定义三个统计变量
        int bignum = 0;
        int smallnum = 0;
        int numbernum = 0;
        
        //遍历字符串,得到每一个字符。
        for(int x=0;x<s.length();x++){
            char ch = s.charAt(x);
            
         //判断该字符到底是属于那种类型的
            if(ch>='A' && ch<='Z'){
                bignum++;
            }
            else if(ch>='a' && ch<='z'){
                smallnum++;
            }
            else if(ch>='0' && ch<='9'){
                numbernum++;
            }
        }
        //输出结果。
        System.out.println("含有"+bignum+"个大写字母");
        System.out.println("含有"+smallnum+"个小写字母");
        System.out.println("含有"+numbernum+"个数字");

使用道具

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

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-4 20:07