Write and run SAS programs in your web browser

SAS Macro | Iterative Processing

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

SAS Macro | Iterative Processing

Need help with the following problem statement:

 

A macro to create the following dataset

var_1 var_2 ........var_9 var_10

1 4 ........81 100

1 8 ......729 1000

 

Thanks in Advance!


Accepted Solutions
Solution
‎06-29-2016 06:34 AM
Esteemed Advisor
Posts: 6,698

Re: SAS Macro | Iterative Processing

No macro needed, just a data step with loops and an array:

data want;
array vars{*} var1-var10;
do n = 2 to 3;
  var1 = 1;
  do i = 2 to dim(vars);
    vars{i} = i ** n;
  end;
  output;
end;
drop i n;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎06-29-2016 06:34 AM
Esteemed Advisor
Posts: 6,698

Re: SAS Macro | Iterative Processing

No macro needed, just a data step with loops and an array:

data want;
array vars{*} var1-var10;
do n = 2 to 3;
  var1 = 1;
  do i = 2 to dim(vars);
    vars{i} = i ** n;
  end;
  output;
end;
drop i n;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 9

Re: SAS Macro | Iterative Processing

Many Thanks!Smiley Happy

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 282 views
  • 1 like
  • 2 in conversation