BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chirumalla
Calcite | Level 5

Hi monthly I will receive weekly datasets like XYZ_WK1,   XYZ_WK2. few months I will receive 4 and few months 5. when I use SET/APPEND to Append data to Base table when one file is missed showing error message how to over come irrespective of datasets number need to append all data sets which are available.

data SOURCE.XYZ ;

set TARGET.XYZ_wk1

     TARGET.XYZ_wk2

     TARGET.XYZ_wk3

     TARGET.XYZ_wk4

     TARGET.XYZ_wk5

  ;

run;

or

proc append base=SOURCE.XYZ data=TARGET.XYZ_wk1;

run;

proc append base=SOURCE.XYZ data=TARGET.XYZ_wk2;

run;

proc append base=SOURCE.XYZ data=TARGET.XYZ_wk3;

run;

proc append base=SOURCE.XYZ data=TARGET.XYZ_wk4;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Here is one way:

proc sql noprint;

  select catx('.',libname,memname)

    into :files separated by ' '

      from dictionary.tables

        where libname="TARGET" and

              memname like "XYZ%"

  ;

quit;

data target.xyz;

  set &files.;

run;

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

Here is one way:

proc sql noprint;

  select catx('.',libname,memname)

    into :files separated by ' '

      from dictionary.tables

        where libname="TARGET" and

              memname like "XYZ%"

  ;

quit;

data target.xyz;

  set &files.;

run;

Tom
Super User Tom
Super User

I think your list of dataset names will need to include the libname.

select catx('.',libname,memname) ....

art297
Opal | Level 21

Tom,

You are absolutely correct, me bad, and I corrected my original post based on your post.  As for the wild card, I didn't suggest it as (as I recall) that was only made available as of 9.3

Art

Tom
Super User Tom
Super User

If your names all start with the same prefix then you could use a wildcard in the SET statement.  (Note your LIBREF names seems backwards to me so I have reversed them in my example code below).

data target.xyz ;

  set source.xyz_wk: ;

run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1471 views
  • 0 likes
  • 3 in conversation