Can I write two different variable names in the array as shown below if not how would i change the code below?
array diag{*} MAIN_PROBLEM OTHER_PROBLEM_:;
do i = 1 to dim(diag);
if diag{i} in ('L400' 'L401' 'L403' 'L409') then gpp = 1;
if diag{i} in: ('O04' 'O07' 'P964') then TA = 1;
end;
/* exclude TA */
array interv{*} MAIN_INTERVENTION OTHER_INTERVENTION_:
do j=1 to dim(interv);
if interv{j} in: ('5CA20' '5CA24' '5CA88' '5CA89' '5CA90') then TA = 1;
end;
names in the array?
Did you actually try running the code? What happened? If there is an error show us the ENTIRE log (that's 100% of the log, every single character, in the order it appears, do not chop out parts) for this DATA step.
To recommend changes we would have to know what the input looks like and the desired output.
Arrays can have a lot of different variables as long as they are of the same type, numeric or character.
What is the question exactly.
Yes you can type as many variables names into an ARRAY statement as you want.
If you use the : wildcard to specify the names by their prefix then the variables have a to already exist in the data step.
But if you list them explicitly and those names do not already exist they will be created.
So a statement like:
array diag MAIN_PROBLEM OTHER_PROBLEM_:;
Will define the array DIAG with one or more variables, depending on how many existing variables have names that start with OTHER_PROBLEM_.
Thankyou All
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.