Hello,
I need to declare a 2D macro array before the following code and fill the partucular elements of the array with some value.
%do ii=1 %to &countlnt;
%let row = %eval(%scan(&myw,&ii , *)); --> this will be the row of the macro array
%let col = %eval(%scan(&myy,&ii , *)-¤tYear+11); --> this will be the column of the macro array
%let value = %eval(%scan(&mycount,&ii , *)); --> and this is the value for the cell (row,col)
%put &mycol ;
%end;
I am very new in SAS. I would really be appriciated if somebody help me. Thank you in advance!
This is likely the wrong assignment for someone who is relatively new to SAS. DATA steps permit 2D arrays. Macros really don't support arrays at all. So check with a local SAS programmer to see that this is the right approach for the problem you are trying to solve. At any rate, you can simulate an array in macro language by using naming conventions for your macro variables. For example, you could add this statement:
%let val_&row._&col. = &value;
That might replace the %PUT statement (which would likely have to be changed anyway, since there is nothing in this code that creates &MYCOL).
At the end of this, at least for testing purposes, you might want to see what you have created, by adding:
%put _user_;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.