Help using Base SAS procedures

how do i use 'two different %do to %num Macro procedure ?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

how do i use 'two different %do to %num Macro procedure ?

I want to SET temp&k and 'DATA Complete&i'

   %do k = 1 %to 100
   %do i = 1 %to 60

data complete&i

     set temp&k

K order(1 to 100) have to proceed the end of I(1 to 60) procedure

thank you.


Accepted Solutions
Solution
‎10-28-2014 10:32 AM
Super User
Posts: 10,500

Re: how do i use 'two different %do to %num Macro procedure ?

To use the %do constructs it will need to be within an actual macro defined using %macro/%mend.

%macro example;

%do k = 1 %to 100;

     %do j= 1 %to 60;

     data complete&j;

          set temp&k;

     run;

     %end; /* ends the j loop*/

%end; /* ends the k loop*/

%mend;

And then call the defined macro:

%example;

I used k as I am tired of fighting with the editor about lower case "i".

View solution in original post


All Replies
Solution
‎10-28-2014 10:32 AM
Super User
Posts: 10,500

Re: how do i use 'two different %do to %num Macro procedure ?

To use the %do constructs it will need to be within an actual macro defined using %macro/%mend.

%macro example;

%do k = 1 %to 100;

     %do j= 1 %to 60;

     data complete&j;

          set temp&k;

     run;

     %end; /* ends the j loop*/

%end; /* ends the k loop*/

%mend;

And then call the defined macro:

%example;

I used k as I am tired of fighting with the editor about lower case "i".

Occasional Contributor
Posts: 12

Re: how do i use 'two different %do to %num Macro procedure ?

Thank you so much.

Super User
Super User
Posts: 7,401

Re: how do i use 'two different %do to %num Macro procedure ?

Hi,

data complete&i.;

     set complet&i. temp&k.;

run;

Or you could use append.

I would ask though, why you have 100 complete tables and 60 temp tables, surely there are better methods to get the end result?

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 225 views
  • 0 likes
  • 3 in conversation