BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kurt_Bremser
Super User

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
Fluorite | Level 6
 
Kurt_Bremser
Super User

@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.

Tom
Super User Tom
Super User

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?

Raitag
Fluorite | Level 6
the second format
the nbimpYYYYMM are variables that contains month in their name

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 19 replies
  • 1993 views
  • 0 likes
  • 7 in conversation