SAS: concatenate different datasets while keeping the individual data table names

前端 未结 2 719
醉梦人生
醉梦人生 2021-01-04 08:54

I\'m trying to concatenate multiple datasets in SAS, and I\'m looking for a way to store information about individual dataset names in the final stacked dataset.

For

相关标签:
2条回答
  • 2021-01-04 09:07

    If you have SAS 9.2 or newer you have the INDSNAME option http://support.sas.com/kb/34/513.html

    So:

    data final;
    format dsname datasetname $20.; *something equal to or longer than the longest dataset name including the library and dot;
    set my_data_1 abc xyc indsname=dsname;
    datasetname=dsname;
    run;
    
    0 讨论(0)
  • 2021-01-04 09:16

    Use the in statement when you set each data set:

    data final;
     set my_data_1(in=a) abc(in=b) xyc(in=c);
     if a then var_3='my_data_1';
     if b then var_3='abc';
     if c then var_3='xyz';
    run;
    
    0 讨论(0)
提交回复
热议问题