BookmarkSubscribeRSS Feed
AlG
Quartz | Level 8 AlG
Quartz | Level 8

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!

 

4 REPLIES 4
Tom
Super User Tom
Super User

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'
AlG
Quartz | Level 8 AlG
Quartz | Level 8

@Tom 

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
Kurt_Bremser
Super User

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.

AlG
Quartz | Level 8 AlG
Quartz | Level 8

@Kurt_Bremser 

Thank you so much. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 506 views
  • 2 likes
  • 3 in conversation