BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nietzsche
Lapis Lazuli | Level 10

Hello, I don't understand why SAS runs fine when I run the following code with drop option before the stat keywords mean and std and gives me the desired result.

 

proc means data=sashelp.cars (drop=origin) mean std;
run;

Nietzsche_3-1670713218050.png

 

But when I follow the book's syntax order and put the DROP option after the stat keywords, it crashes

 

Nietzsche_5-1670713337306.png

 


proc means data=sashelp.cars mean std (drop=origin); run;

Nietzsche_2-1670713165126.png

 

 

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

DROP= is a dataset option, and therefore an integral part of the DATA= procedure option. You must not separate dataset options from their dataset name. Keep in mind that a single statement may have multiple options naming datasets (e.g. DATA=, OUT=, DUPOUT= in a PROC SORT), and it must be clear which dataset options belong to which dataset.

View solution in original post

12 REPLIES 12
ger15xxhcker
Quartz | Level 8

The order in which you specify the options in PROC MEANS matters. When you specify the DROP option before the stat keywords MEAN and STD, the SAS compiler is aware that you want to drop the ORIGIN variable from the calculation of the MEAN and STD. However, when you specify the DROP option after the stat keywords, the SAS compiler does not recognize it, therefore it crashes.

Nietzsche
Lapis Lazuli | Level 10

Does that mean the book got the order of the syntax wrong? 

it looks like it that way from the documentation on PROC MEANS

Nietzsche_0-1670714587475.png

 

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
SASKiwi
PROC Star

No, you also need to look at the documentation covering DATASET OPTIONS

SASKiwi
PROC Star

DROP = is a dataset OPTION and must immediately follow the dataset it applies to inside brackets. The PROC MEANS statement has its own options. They don't require brackets and can be specified in any order after PROC MEANS.

 

Also SAS has not crashed. All that has happened is SAS has stopped running the MEANS step because of the syntax error.

Nietzsche
Lapis Lazuli | Level 10

The PROC MEANS statement has its own options. They don't require brackets and can be specified in any order after PROC MEANS.

yeah they do require parentheses, otherwise SAS will give an error, and I just given an example that shows order DOES matter.

Nietzsche_0-1670715099774.png

 

 

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
SASKiwi
PROC Star

You are confusing DATASET OPTIONS  - brackets required - and PROCEDURE OPTIONS - no brackets required. See the documentation link in my earlier response.

Nietzsche
Lapis Lazuli | Level 10

You are confusing DATASET OPTIONS  - brackets required - and PROCEDURE OPTIONS - no brackets required. See the documentation link in my earlier response.

I really have no idea that you're talking about. if you could come up with examples using the sashelp.cars so I can understand what you're trying to convey.

 

And () are called parenthesis, [] are brackets, do you mean () outside the drop option?

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
SASKiwi
PROC Star

Hopefully this documentation link will help.

 

A DATASET option example:

proc print data = sashelp.class (drop = age); * Dataset option;
run;

proc print data = sashelp.class label; * procedure statement option;
run;

 

 

 

Nietzsche
Lapis Lazuli | Level 10

() are round brackets, [] are square brackets, and {} curly brackets (https://www.englishclub.com/writing/punctuation-brackets.htm).

okay, in other programming communities, like python, they call () strictly parenthesis and [] brackets to avoid confusion when making list and tuples.

 

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
Tom
Super User Tom
Super User

There is no DROP option on the PROC MEANS statement.  Read the manual.

Your code does not include any DROP option anyway.

The working example is using the DROP= dataset option

The failed code is an example of misplaced set of dataset options.

Kurt_Bremser
Super User

DROP= is a dataset option, and therefore an integral part of the DATA= procedure option. You must not separate dataset options from their dataset name. Keep in mind that a single statement may have multiple options naming datasets (e.g. DATA=, OUT=, DUPOUT= in a PROC SORT), and it must be clear which dataset options belong to which dataset.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 12 replies
  • 2270 views
  • 3 likes
  • 5 in conversation