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
SAS Super FREQ
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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1305 views
  • 0 likes
  • 2 in conversation