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_;
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.