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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.