BookmarkSubscribeRSS Feed

Question about error for array and var names

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

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Labels
Article Tags