BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
kindbe17
Fluorite | Level 6

how can i fix the syntax error?

 

proc sql;
create table cars11 as
select make,
type,
Mean (horsepower) as Mean1,
Mean (invoice) as Mean2,
Mean (weight) as Mean3,
From sashelp.cars,
Group by make, type;
quit;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

No comma after the last variable name and before FROM

Also no comma after FROM SASHELP.CARS

 

proc sql;
    create table cars11 as
    select make,
       type,
       Mean (horsepower) as Horsepower_Mean,
       Mean (invoice) as Invoice_Mean,
       Mean (weight) as Weight_Mean
    from sashelp.cars
    group by make, type;
quit;

 

 

Pro tip: putting the commas before the variable in PROC SQL and indenting the code helps eliminate the first error, which is a common error

 

proc sql;
    create table cars11 as select 
       make
       ,type
       ,Mean (horsepower) as Horsepower_Mean
       ,Mean (invoice) as Invoice_Mean
       ,Mean (weight) as Weight_Mean
    from sashelp.cars
    group by make, type;
quit;

 

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

No comma after the last variable name and before FROM

Also no comma after FROM SASHELP.CARS

 

proc sql;
    create table cars11 as
    select make,
       type,
       Mean (horsepower) as Horsepower_Mean,
       Mean (invoice) as Invoice_Mean,
       Mean (weight) as Weight_Mean
    from sashelp.cars
    group by make, type;
quit;

 

 

Pro tip: putting the commas before the variable in PROC SQL and indenting the code helps eliminate the first error, which is a common error

 

proc sql;
    create table cars11 as select 
       make
       ,type
       ,Mean (horsepower) as Horsepower_Mean
       ,Mean (invoice) as Invoice_Mean
       ,Mean (weight) as Weight_Mean
    from sashelp.cars
    group by make, type;
quit;

 

--
Paige Miller
kindbe17
Fluorite | Level 6

i have an error again;

 

Syntax error, expecting one of the following: ',', GROUP, ORDER.

Oligolas
Barite | Level 11

remove the semicolons after Mean3 and sashelp.cars

________________________

- Cheers -

kindbe17
Fluorite | Level 6

Thank you

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1333 views
  • 0 likes
  • 4 in conversation