BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All,

I use:-


data exam;
input name $ class $ score ;
cards;
Tim math 9
Tim history 8
Tim science 7
Sally math 10
Sally science 7;
run;


data student1;
set exam;
where name = ‘Tim’ or name = ‘Sally’;
run;

I get error:

ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, (, *, +, -, :, INPUT, NOT,
PUT, ^, ~.


Kindly guide.
K.
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
I can duplicate your error message if I cut and paste code from Microsoft Word that uses "slanted" quotes instead of "regular" quotes. For example:
[pre]
142 where name = ‘Tim’ or name = ‘Sally’;
-
22
76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, (, *, +, -, :,
INPUT, NOT, PUT, ^, ~.

ERROR 76-322: Syntax error, statement will be ignored.

143 run;
[/pre]

Notice the "slanted" quote marks. If, on the other hand, I type in Notepad or in SAS Display Manager or use the "unslanted" quotes, the WHERE statement does not generate an error message:
[pre]
158 where name = 'Tim' or name = 'Sally';
159 run;

NOTE: There were 5 observations read from the data set WORK.EXAM.
WHERE name in ('Sally', 'Tim');
NOTE: The data set WORK.STUDENT1 has 5 observations and 3 variables.
[/pre]

Perhaps if you try retyping your WHERE clause and ensure that there are no "slanted" quotes, you will have success.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1527 views
  • 0 likes
  • 2 in conversation