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