导出 SAS 数据集中的变量类型 [英] Export the types of variables in a SAS dataset

查看:42
本文介绍了导出 SAS 数据集中的变量类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么简单的方法可以捕获和导出 SAS 数据集中每个变量的类型?我正在将数据集导出为 CSV 格式以读入 R,如果后者中的 read.table 过程也知道每个变量的数据类型,它可以更有效地工作.

Is there any easy way to capture and export the type of each variable in a SAS dataset? I'm exporting a dataset to CSV format to read into R, and the read.table procedure in the latter can work more efficiently if it also knows the data type of each variable.

推荐答案

PROC CONTENTS 有一个 OUT= 选项来输出具有可变属性的数据集.type=1 是数字,type=2 是字符.哈.

PROC CONTENTS has an OUT= option to ouput a dataset with variable attributes. type=1 is numeric and type=2 is character. HTH.

   proc contents data=sashelp.class out=vars;
   run;

   proc print data=vars noobs;
     var varnum name type length;
   run;
   /* on lst
   VARNUM    NAME      TYPE    LENGTH

      3      Age         1        8
      4      Height      1        8
      1      Name        2        8
      2      Sex         2        1
      5      Weight      1        8
   */

这篇关于导出 SAS 数据集中的变量类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆