how to put the name of a dataset as a column in SAS

风流意气都作罢 提交于 2019-12-25 14:03:40

问题


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


回答1:


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

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

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;

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.



来源:https://stackoverflow.com/questions/32187021/how-to-put-the-name-of-a-dataset-as-a-column-in-sas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!