Hi Experts,
I have a problem getting numeric values for a Macro variable in a do loop. Example codes are:
%Macro abcd(aa=0.44 0.3 2 1, st=1, ed=4);
data abc;
M=1;
V=100;
%do i=&st %to &ed;
%LET wt=%scan(&aa, &i);
MT=M+V; output;
%PUT &wt;
%END;
RUN;
%MEND;
%abcd;
I am getting values 0, 44, 0, 3 instead of 0.44, 0.3, 2, 1. Please help me getting the correct value for each iteration.
Thank you
Hitesh
You probably need the third argument in the %SCAN function to indicate that a space is the delimiter.
%LET wt=%scan(&aa, &i, %str( ));
You probably need the third argument in the %SCAN function to indicate that a space is the delimiter.
%LET wt=%scan(&aa, &i, %str( ));
Thank you very much Paige, You saved my day!
Your macro makes no sense to me, as it does NOTHING except put some text into the log and making the data step create 4 identical observations.
Hi Kurt,
It was just sample code. I am using that to provide different weights to different year data in my actual macro where these values need to provide by user and can vary for each year.
Thanks for the response.
Hitesh
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!
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.