DATA Step, Macro, Functions and more

Error message to array declaration

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Error message to array declaration

Not quite sure what the wrong place is in my array declaration. Log messege is after the code. I created two character arrays and want to pass old variables to newly-defined variables.

 

Many thanks for help

 

Code:

 

DATA SOURCE2;
 SET RAW.SOURCE2;
 INPUT PE $ FR $ EE $ AD $ VAR1-VAR10 $;
 ARRAY NEWVAR[*] $ PUBDATE FRCTQTR ESTTYPE ANALID VAR1-VAR10;
 ARRAY OLDVAR[*] $ A B C D E F G H I J K L M N;
 
 DO X = 1 TO DIM(NEWVAR);
  NEWVAR[X] = OLDVAR[X];
 END;
 DROP A B C D E F G H I J K L M N;
RUN;

 

Log messege

 

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

55
56 DATA SOURCE2;
57 SET RAW.SOURCE2;
58 INPUT PUBDATE $ FRCTQTR $ ESTTYPE $ ANALID $ VAR1-VAR10 $;
59 ARRAY NEWVAR[*] $ PUBDATE FRCTQTR ESTTYPE ANALID VAR1-VAR10;
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
60 ARRAY OLDVAR[*] $ A B C D E F G H I J K L M N;
61
62 DO X = 1 TO DIM(NEWVAR);
63 NEWVAR[X] = OLDVAR[X];
64 END;
65 DROP A B C D E F G H I J K L M N;
66 RUN;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SOURCE2 may be incomplete. When this step was stopped there were 0 observations and 15 variables.
WARNING: Data set WORK.SOURCE2 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.04 seconds

Accepted Solutions
Solution
‎02-26-2016 01:34 AM
Super User
Posts: 17,750

Re: Error message to array declaration

You've got a few things going on there.

 

I'm not sure why you have a SET and INPUT? Input is made to read data in, I don't think you're doing that. Remove that line entirely. 

 

Check the variable types of the old variable from RAW.SOURCE2 -> PROC CONTENTS. Check that all the variables are character already.

 

It also looks like you might be mixing up your old/new variables but I can't even be sure right now.

 

 

 

 

 

View solution in original post


All Replies
Solution
‎02-26-2016 01:34 AM
Super User
Posts: 17,750

Re: Error message to array declaration

You've got a few things going on there.

 

I'm not sure why you have a SET and INPUT? Input is made to read data in, I don't think you're doing that. Remove that line entirely. 

 

Check the variable types of the old variable from RAW.SOURCE2 -> PROC CONTENTS. Check that all the variables are character already.

 

It also looks like you might be mixing up your old/new variables but I can't even be sure right now.

 

 

 

 

 

Occasional Contributor
Posts: 14

Re: Error message to array declaration

Variables A to N are old variables. I like to replace with a set of appropriate new variables by using array. I checked, all the variables, A to N, are character already.

 

Just a qucik clarification needed. About INPUT statement, would you mean, in general case, it will be used for read data in such as using DATALINE for data creation?

 

Alphabetic List of Variables and Attributes # Variable Type Len Format Informat Label 1 2 3 4 5 6 7 8 9 10 11 12 13 14

AChar16$16.$16.A
BChar16$16.$16.B
CChar12$12.$12.C
DChar16$16.$16.D
EChar10$10.$10.E
FChar10$10.$10.F
GChar15$15.$15.G
HChar15$15.$15.H
IChar14$14.$14.I
JChar15$15.$15.J
KChar15$15.$15.K
LChar16$16.$16.L
MChar16$16.$16.M
NChar15$15.$15.N
Occasional Contributor
Posts: 14

Re: Error message to array declaration

Hi! I started over my University Edition and removed the INPUT statement as you said. The program works now. Thanks!!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 541 views
  • 0 likes
  • 2 in conversation