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);
.
.
.
run;
(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!
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.
Chris
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:
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.