BookmarkSubscribeRSS Feed

Question about error for array and var names

Started ‎02-20-2015 by
Modified ‎10-05-2015 by
Views 1,599

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!

Comments

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:

Version history
Last update:
‎10-05-2015 03:29 PM
Updated by:

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

SAS AI and Machine Learning Courses

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.

Get started

Article Labels
Article Tags