BookmarkSubscribeRSS Feed
astha8882000
Obsidian | Level 7

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.

2 REPLIES 2
Reeza
Super User
TOP 2 is not valid SAS syntax. You can OUTOBS= on the PROC SQL statement instead.
Kurt_Bremser
Super User

@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.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 714 views
  • 1 like
  • 3 in conversation