Variable with tables's names SAS

I want to create custom variable that will store table's name from which observation is comming from.

Something like this:

data FTTH_SOHO_2;
    ATTRIB scoring_month;
    set fmscore.SCORE_FTTH_CHURN_SOHO_202009 - fmscore.SCORE_FTTH_CHURN_SOHO_202012
    fmscore.SCORE_FTTH_CHURN_SOHO_202101 - fmscore.SCORE_FTTH_CHURN_SOHO_202106 = tablename;
    scoring_month = tablename;
    where tp_desig_num = 'XXXXXXXXXXX';
run;

Ofcourse I get syntax error but is it possible to store the name of currety used Data Set to some kind variable and use it to mark with it observation from which it came from?

I need to see months from which I recive observations.

Upvotes: 0

Views: 208

Answers (1)

Joe
Joe

Reputation: 63434

You're looking for the INDSNAME option.

data want;
  set have1 have2 have3 indsname=dsn;
  ds_name = dsn;
run;

You do have to create a variable with an assignment statement separate from the indsname option, as the option creates only a temporary variable.

Upvotes: 1

Related Questions