楼主: jdzz
4246 6

[编程问题求助] 当一个数据库变量很多时,如何迅速找到某一数据类型的变量? [推广有奖]

已卖:111份资源

教授

16%

还不是VIP/贵宾

-

威望
0
论坛币
5006 个
通用积分
311.3593
学术水平
13 点
热心指数
15 点
信用等级
9 点
经验
24799 点
帖子
795
精华
0
在线时间
804 小时
注册时间
2010-2-4
最后登录
2024-12-23

楼主
jdzz 发表于 2015-12-2 18:58:35 |AI写论文
3论坛币
300多个变量,想找到字符型变量有哪些,如何快速找到?

最佳答案

夏目贵志 查看完整内容

如截图所示,可以使用stata自带的filter
关键词:数据类型 数据库 字符型变量 多个变量 如何快速 数据库 如何

本帖被以下文库推荐

沙发
夏目贵志 发表于 2015-12-2 18:58:36
2015-12-03 00_18_28-Stata_MP 14.0.png
如截图所示,可以使用stata自带的filter

藤椅
raymondxiang 发表于 2015-12-3 12:35:39
打开browser看,哪些颜色是暗红色的,哪些就是string variable吧

板凳
jdzz 发表于 2015-12-4 10:57:35
夏目贵志 发表于 2015-12-3 13:19
如截图所示,可以使用stata自带的filter
如果只想列出字符型变量,不希望遗漏呢?

报纸
夏目贵志 发表于 2015-12-4 10:59:59
jdzz 发表于 2015-12-4 10:57
如果只想列出字符型变量,不希望遗漏呢?
不希望遗漏
不明白你是什么意思

地板
jdzz 发表于 2015-12-4 11:32:23
夏目贵志 发表于 2015-12-4 10:59
不明白你是什么意思
因为变量数量比较多,300多,想集中起来看哪几个变量是字符型的,如何用命令实现?

7
蓝色 发表于 2015-12-4 12:14:51
多看看data management的那本手册
大致看看人家都有什么功能

ds




Title

    [D] ds -- List variables matching name patterns or other characteristics


Syntax

    Simple syntax

        ds [, alpha]

    Advanced syntax

        ds [varlist] [, options]

    options                   Description
    ----------------------------------------------------------------------------------------
    Main
      not                     list variables not specified in varlist
      alpha                   list variables in alphabetical order
      detail                  display additional details
      varwidth(#)             display width for variable names; default is varwidth(12)
      skip(#)                 gap between variables; default is skip(2)

    Advanced
      has(spec)               describe subset that matches spec
      not(spec)               describe subset that does not match spec

      insensitive             perform case-insensitive pattern matching
      indent(#)               indent output; seldom used
    ----------------------------------------------------------------------------------------
    insensitive and indent(#) are not shown in the dialog box.

    spec                      Description
    ----------------------------------------------------------------------------------------
    type typelist             specified types
    format patternlist        display format matching patternlist
    varlabel [patternlist]    variable label or variable label matching patternlist
    char [patternlist]        characteristic or characteristic matching patternlist
    vallabel [patternlist]    value label or value label matching patternlist
    ----------------------------------------------------------------------------------------

    typelist used in has(type typelist) and not(type typelist) is a list of one or more
        types, each of which may be numeric, string, str#, strL, byte, int, long, float, or
        double, or may be a numlist such as 1/8 to mean "str1 str2 ...  str8".  Examples
        include

            has(type int)                 is of type int
            has(type byte int long)       is of integer type
            not(type int)                 is not of type int
            not(type byte int long)       is not of the integer types
            has(type numeric)             is a numeric variable
            not(type string)              is not a string (str# or strL) variable (same as
                                            above)
            has(type 1/40)                is str1, str2, ..., str40
            has(type str#)                is str1, str2, ..., str2045 but not strL
            has(type strL)                is of type strL but not str#
            has(type numeric 1/2)         is numeric or str1 or str2

    patternlist used in, for instance, has(format patternlist), is a list of one or more
        patterns.  A pattern is the expected text with the addition of the characters * and
        ?.  * indicates 0 or more characters go here, and ? indicates exactly 1 character
        goes here.  Examples include

            has(format *f)                format is %#.#f
            has(format %t*)               has time or date format
            has(format %-*s)              is a left-justified string
            has(varl *weight*)            variable label includes word weight
            has(varl *weight* *Weight*)   variable label has weight or Weight

    To match a phrase, enclose the phrase in quotes.

            has(varl "*some phrase*")    variable label has some phrase

    If instead you used has(varl *some phrase*), then only variables having labels ending in
        some or starting with phrase would be listed.


Menu

    Data > Describe data > Compactly list variable names


Description

    ds lists variable names of the dataset currently in memory in a compact or detailed
    format, and lets you specify subsets of variables to be listed, either by name or by
    properties (for example, the variables are numeric).  In addition, ds leaves behind in
    r(varlist) the names of variables selected so that you can use them in a subsequent
    command.

    ds, typed without arguments, lists all variable names of the dataset currently in memory
    in a compact form.
已有 1 人评分经验 热心指数 收起 理由
夏目贵志 + 10 + 2 热心帮助其他会员

总评分: 经验 + 10  热心指数 + 2   查看全部评分

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-6 03:47