something like
array nbimp2016 {*} nbimp201601-nbimp201606;
month_check = month(&date_risk);
if (nbimp2016{month_check} >= 3)
then HR_3 = 1;
else HR_3 = 0;
In the same vein, you could create a two-dimensional array with years and months.
@Raitag wrote:
Sorry i clicked on the wrong button
But by defining a two dimensional array i will have all my nbimpYYYYMM s value set to zero
won't i ?
A SAS array is just a "grid" that can be put upon existing variables to easily address them. It does not change values of variables per se.
If you define variables in the array that do not yet exist, then those are set to missing initially.
Edit:
and if you have lots of those nbimp variables, it will make sense to use macro programming to create the array definition.
Your problem does not look like something that needs to use macro code. But your description of your data and the code you posted are at odds. The code seems to be thinking there is a variable with the month in it,
PRODUCT|MONTH|VALUE 101|201606|25 101|201607|35
but the description seemed to say that the month is actually coded into the name of the variable.
PRODUCT|VAL201606|VAL201607 101|25|35
Which format is the data actually in?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.