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


Hi all,

is there a way to merge a lot of datsets with increasing suffixes?

data mydataset;

     merge step1 step2 step3 [...] step27;

     by myvar;

run;

is very long to write.

data mydatset;

     merge step1 - step27;

     by myvar;

run;

doesn't work...

any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

With a macro:

data mydataset;

merge

  %macro datasets;

  %do i = 1 %to 27;

  step&i

  %end;

  %mend;

  %datasets

;

by myvar;

run;

But you don't need that, as others already said, the set1-set27 solution works at least in 9.2.

View solution in original post

5 REPLIES 5
Ksharp
Super User

What version of sas are you using ? I can run your code.

Lupacante
Calcite | Level 5

SAS enterprise guide

Haikuo
Onyx | Level 15

Merge statement supports data sets lists, so It should work.

Please elaborate more on  "doesn't work...". Did it throw an error message or it didn't work the way you expected? Do you have the log? More details would be helpful.

So you are using the Eguide, but what version? 4.3/5.1 or 6.1?

Regards,

Haikuo

Lupacante
Calcite | Level 5

IT's 4.1.

It doesn't run at all, just gives an error message.

It's ok though, I've solved it by writing a macro around it as RW9 suggested.

Thanks for your answers

Kurt_Bremser
Super User

With a macro:

data mydataset;

merge

  %macro datasets;

  %do i = 1 %to 27;

  step&i

  %end;

  %mend;

  %datasets

;

by myvar;

run;

But you don't need that, as others already said, the set1-set27 solution works at least in 9.2.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 941 views
  • 0 likes
  • 4 in conversation