- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
But when I follow the book's syntax order and put the DROP option after the stat keywords, it crashes
proc means data=sashelp.cars mean std (drop=origin); run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Does that mean the book got the order of the syntax wrong?
it looks like it that way from the documentation on PROC MEANS
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No, you also need to look at the documentation covering DATASET OPTIONS
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You are confusing DATASET OPTIONS - brackets required - and PROCEDURE OPTIONS - no brackets required. See the documentation link in my earlier response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
() are round brackets, [] are square brackets, and {} curly brackets (https://www.englishclub.com/writing/punctuation-brackets.htm).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
() 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.