问题
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