如何将数据集的名称作为 SAS 中的列 [英] how to put the name of a dataset as a column in SAS

查看:29
本文介绍了如何将数据集的名称作为 SAS 中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SAS 中有一个非常基本的问题.例如,如果数据集名为a",我如何将a"作为新列放入该数据集中?非常感谢

I have a very basic question in SAS. for example, if the dataset called 'a', how can I put 'a' as a new column into this dataset? Thank you very much

推荐答案

基本上你不能.您可以创建一个新数据集.

Basically you can't. You can make a new dataset.

data new;
  set old;
  dsname='NEW';
run;

您可以在 SET 语句中使用 INDSNAME 选项来告诉您正在从哪个数据集读取数据.

You can use the INDSNAME option on the SET statement to tell you which dataset you are reading data from.

data new ;
   length indsname dsname $41 ;
   set old indsname=indsname ;
   dsname = indsname ;
run;

当 SET 语句引用多个数据集时更有意义.您需要定义两个变量,因为由 INDSNAME= 选项定义的变量会被自动删除.

Makes more sense when the SET statement has more than one dataset referenced. You need to define two variables because the one defined by the INDSNAME= option is automatically dropped.

这篇关于如何将数据集的名称作为 SAS 中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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