BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
twildone
Pyrite | Level 9

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, ^=, |, ||, ~=.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

3 REPLIES 3
Kurt_Bremser
Super User

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?

Reeza
Super User

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";

ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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