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-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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