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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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