DATA Step, Macro, Functions and more

Error in simple code

Reply
Occasional Contributor
Posts: 8

Error in simple code

I'm trying to view the contents of a dataset in the SASHelp library, but it gives me these errors. I'm not sure what is wrong with my simple code:

 

Code:

proc sql;
Select top 2 * from sashelp.aacomp;
quit;

 

Errors:

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

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

Super User
Posts: 23,224

Re: Error in simple code

Posted in reply to astha8882000
TOP 2 is not valid SAS syntax. You can OUTOBS= on the PROC SQL statement instead.
Super User
Posts: 9,860

Re: Error in simple code

Posted in reply to astha8882000

@astha8882000 wrote:

I'm trying to view the contents of a dataset in the SASHelp library, but it gives me these errors. I'm not sure what is wrong with my simple code:

 

Code:

proc sql;
Select top 2 * from sashelp.aacomp;
quit;

 

Errors:

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

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


Your select has two items, a variable called top and the literal 2. These items need to be separated by a comma to get valid SQL syntax.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 2 replies
  • 66 views
  • 1 like
  • 3 in conversation