How to read variable names in a SAS data set?

后端 未结 5 854
借酒劲吻你
借酒劲吻你 2020-12-28 18:55

Are there any statements\\functions capable of get the name of variables? Preferrably putting them into a column of another data set, a text field or a macro variable.

5条回答
  •  臣服心动
    2020-12-28 19:16

    You can also use a datastep and array functions, e.g.

    data colnames ;
      set sashelp.class (obs=1) ;
    
      array n{*} _NUMERIC_ ;
      array c{*} _CHARACTER_ ;
    
      do i = 1 to dim(n) ;
        vname = vname(n{i}) ;
        output ;
      end ;
      do i = 1 to dim(c) ;
        vname = vname(c{i}) ;
        output ;
      end ;
    run ;
    

提交回复
热议问题