0

I am reading in the following dataset:

  data list;
      set project.daily_list;
    run;

enter image description here

It contains a list of names of other data sets. Currently I am reading in "NBBOM_20140102" as follows:

 data X;
        set nbbo.NBBOM_20140102;
    run;

Question 1: How can I set "nbbo.NBBOM_20140102" by referring to the list? Question 2: How can I do this in a loop? I'd like to set all the datasets in the nbbo column one-by-one via a loop.

amar96
  • 49
  • 5
  • Set them into one data set? Individual one each? I'm assuming you don't want them all called X? Show what the final code should look like please. – Reeza Jun 06 '22 at 19:28
  • https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md – Reeza Jun 06 '22 at 19:34
  • The linked duplicate has really good examples of how to do the general concept of what you're trying to (write code from data). There's a bunch of different approaches you can use. – Joe Jun 07 '22 at 02:57

1 Answers1

1

You can use SQL to concatenate the nbbo column values into a macro variable that is a source code snippet to be used in a SET statement.

Example:

proc sql noprint;
  select 'nbbo.'||nbbo into :nbbo_tables separated by ' '
  from project.daily_list
  ;

* stack all the nbbo tables in the list into a single larger table;

data want;
  set &nbbo_tables indsname=from_table;
  row_from = from_table; * track the source table of the row if needed;
run;
Richard
  • 25,390
  • 3
  • 25
  • 38