BookmarkSubscribeRSS Feed
themanoj20080
Fluorite | Level 6

Hello everyone,

 

I have a macro that takes a dataset, and few other as arguments. I am inside a PROC IML. I am using a do loop and inside a do loop, I am calling a macro that I have already created. How can I update the data set in each loop so that updated data set can be used each time in the loop when I call the macro?

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

I can't imagine this.. Can you post your code please?

Cynthia_sas
SAS Super FREQ
Hi:
There is a separate forum for IML users: https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bd-p/sas_iml your question might be viewed by more IML users in that forum.
Cynthia
ballardw
Super User

If your macro contains any PROC or DATA step blocks it will halt the Proc Iml executing when encounter if it doesn't create an error condition.

 

Just like when I run this code:

 

Data junk;

   set sashelp.class;

   if sex='F' then weight=weight-1;

proc print data=junk;

run;

 

The SAS system when it encounters the PROC "knows" that you intended to end the data step and implies a "run;" statement.

Similarly if another Data step definition is encountered the same thing happens with the currently executing data step or proc terminating so the new data step can start.

 

You would have to post the entire code of the IML attempting to call the macro and the macro definition(s) to see what alternate ideas may be practical.

themanoj20080
Fluorite | Level 6

 

Here is the example. I have a macro and proc iml. In the PROC IML, after the loop ends I want five different means but I am not getting that.
%macro hello(X);
use &dataset; read all var{&X} into A;
m=mean(A);
print m;
%mend hello;

proc iml;
do i = 1 to 5;
X=randnormal(10,0,1);
firstcol=X[,1];
create newdata var{firstcol};
append;
close;
%let dataset=newdata;
%hello(firstcol);
call delete(dataset);
end;
quit;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1083 views
  • 0 likes
  • 4 in conversation