DATA Step, Macro, Functions and more

re: error message

Accepted Solution Solved
Reply
Regular Contributor
Posts: 222
Accepted Solution

re: error message

Hi...I am getting an error message and this error message occurs if I try to include an alphabet letter as part of a number. It works if I only have all numbers. The thing is that I had used a letter with the numbers before and it worked fine...not to sure what has changed since. Any suggestions how to correct this...Thanks.

 

%LET BULLETIN = 79A;

log output:

 

376       DATA Bulletin;

 

377            Bulletin_Number=&bulletin;

NOTE: Line generated by the macro variable "BULLETIN".

377       79A

             _

             22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN,

             LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.


Accepted Solutions
Solution
‎01-05-2017 12:58 PM
Super User
Posts: 17,737

Re: re: error message

Your syntax is invalid and this should never have worked. 

 

Bulletin_Number=&bulletin;

 

bulletin = 79A

 

Bulletin_Number=79A; -> this is not valid code, you need quotation marks. 

 

Bulletin_Number="&bulletin";

View solution in original post


All Replies
Super User
Posts: 6,927

Re: re: error message

79A is not a number, and it is not a valid name for a variable, therefore you get the error message in the data step.

 

What type should the data step variable bulletin_number be, and what value do you want to assign to it?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎01-05-2017 12:58 PM
Super User
Posts: 17,737

Re: re: error message

Your syntax is invalid and this should never have worked. 

 

Bulletin_Number=&bulletin;

 

bulletin = 79A

 

Bulletin_Number=79A; -> this is not valid code, you need quotation marks. 

 

Bulletin_Number="&bulletin";

Super User
Posts: 10,460

Re: re: error message

How SAS knows if the variable is numeric or character (your only options in SAS) is usually how the variable is first encountered in a data step. If the first use is an assignment statement such as Bulletin_Number=  then what appears after the equal sign sets the type. If there is not a quoted value then the variable is numeric. Since your example statement had no quotes then the variable created as numeric and numeric values cannot have an "A" or anything except digits, decimals or exponential notation values (3.4E5 for example).

 

If you are trying to learn macro usage without an understanding of basic SAS code and programming behavior then expect a bumpy ride.

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 161 views
  • 0 likes
  • 4 in conversation