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

I have 15 datasets in a library. the data is already sorted. is there a way to merge them all together with out having to write each one out?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

data class1 class2 class3;
  set sashelp.class;
  run;

/*  if your datasets begin with same letters */
  data want;
   merge c:;
   by name;
  run;

/* begin with different letters */

proc sql noprint;
   select memname into : names
     from dictionary.tables
    where libname='WORK'; /* note: libname must be in upcase */
data want;
   merge &names;
   by name;
  run;

View solution in original post

5 REPLIES 5
Linlin
Lapis Lazuli | Level 10

data class1 class2 class3;
  set sashelp.class;
  run;

/*  if your datasets begin with same letters */
  data want;
   merge c:;
   by name;
  run;

/* begin with different letters */

proc sql noprint;
   select memname into : names
     from dictionary.tables
    where libname='WORK'; /* note: libname must be in upcase */
data want;
   merge &names;
   by name;
  run;

SAShole
Pyrite | Level 9

Thanks Lin Lin!

this is just what i was looking for.

Smiley Happy

SAShole
Pyrite | Level 9

the SQL method seems to merge class1 only.

Linlin
Lapis Lazuli | Level 10

sorry. using the updated one:

proc sql noprint;

   select memname into : names separated by '  '

     from dictionary.tables

       where libname='WORK'; /* note: libname must be in upcase */

data want;

   merge &names;

   by name;

  run;

Linlin

MikeZdeb
Rhodochrosite | Level 12

hi ... just modify the code (without "SEPARATED BY" you only get one memname)  ...

proc sql noprint;

select memname into : names separated by ' '

from dictionary.tables

where libname='WORK'; /* note: libname must be in upcase */

quit;

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 11411 views
  • 1 like
  • 3 in conversation