Hi everyone.
In my dataset, I have a column which includes the names of several brands. I want to create a variable which will include another variation of the name of the same brands. Below are the first few lines of my code:
data Test6;
set work.Test5;
If name = “Aeromexico” then MergeName = “Aeromexico”;
Else if name = “Alaska Airlines” then MergeName = “Alaska Air”;
Else if name = “Foster’s Funny” then MergeName = “Fosters”
The reason I am using double quotation is some brand names include single quotation marks.
However, I am getting the following errors from SAS:
ERROR 390-185: Expecting an relational or arithmetic operator.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 76-322: Syntax error, statement will be ignored.
What is wrong with my code? Why am I getting these? Thanks so much inadvance!
You need to copy and paste the actual lines from the log where the error is occurring. SAS will place markers showing exactly where the error is detected so you can figure out what syntax it is complaining about. Make sure to use the Insert Code button (looks like < / > ) to get a pop-up window where you can paste the lines so that they are not treated as paragraphs to be re-flowed.
You don't have to use double quotes on the outside. If the text contains the quote character then just double it.
'Foster''s Funny'
Thanks so much. I am very new to SAS and this community, however I have correctly followed your instruction on how to include the lines from the log. In sum, this error occurs for all of the lines (all of the brand), all under the first double quote. For sum, there are 3 error numbers, for some 2.
410 If name = “Aeromexico” then MergeName = “Aeromexico”; - 390 200 76 411 Else if name = “Air Canada” then MergeName = “Air Canada”; - 390 76 412 Else if name = “Alaska Airlines” then MergeName = “Alaska Air”; - 390 76
You are using a wrong type of double quotes.
” "
If you look closely, you'll see the difference.
Hint: never use a word processor (e.g. MS Word) to edit programs. Use SAS Studio, Enterprise Guide, the Display Manager, or a pure text editor like Notepad++.
Word processors will introduce "nice" features that are not part of valid syntax.
Thank you so much.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.