We’re smarter together. Learn from this collection of community knowledge and add your expertise.

Question about error for array and var names

by Contributor michellel on ‎02-20-2015 11:05 AM - edited on ‎10-05-2015 03:29 PM by Community Manager (234 Views)

Hi, I have questions about array and variables names. Thanks a lot for your answer in advance.


I have some character variables named ABC_1_CD,ABC_2_CD,........ABC_25_CD, which made trouble for me in both keeping variables part and array part.


(1) There will be an error saying "ABC_1_CD does not have a numeric suffix" when I tried to keep these variables as the following.

data new;

     set old(keep = ABC_1_CD - ABC_25_CD);






(2) When I did ARRAY, trying to find if these 25 variables contain some 'word', there were two errors shown as the following.


ERROR: Alphabetic prefixes for enumerated variables {ABC_1_CD - ABC_25_CD} are different.

ERROR: Too few variables defined for the dimension(s) specified for the array.


I think the reason for both of the above two parts is the variable name. The number in variables are in the middle, instead of at the end. If so, could any one of you tell me how to write the code? Thanks much!

by Community Manager
on ‎02-20-2015 01:09 PM

Try this style of syntax:

  set old (keep=ABC:);

The colon serves as sort of a wildcard and will match all of the variables with the "ABC" prefix.


PS: in the future, you should use the Discussion feature (instead of creating an article/document) to ask a question in the community.  See this article for guidance:

Your turn
Sign In!

Want to write an article? Sign in with your profile.

Looking for the Ask the Expert series? Find it in its new home: communities.sas.com/askexpert.