- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello SAS Community,
If I need the average of 3 numbers I can use
mean (number1, number2, number3)
that will give me the average of the 3 variables
If I use instead
mean (number1 + number2 + number3)
SAS will (rightly) compute the sum of the 3 numbers.
Would you consider typing
mean (number1 + number2 + number3)
if what I need is
mean (number1, number2, number3)
a LOGIC or a SYNTAX error?
Thanks in advance.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Anne_A,
without having more context, I would assume a logic error.
Best
Markus
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Anne_A,
without having more context, I would assume a logic error.
Best
Markus
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Markus,
So would I. The thing is, in the SAS Certified Specialist prep guide (pp 63-64), this is provided as an example of syntax error - I was puzzled hence my question.
I will keep considering this a logical error, praying for the exam questions not to be too close to the prep guide's content ... 😉.
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If it was a syntax error, there would be errors in the LOG.
You can type all sorts of ridiculous things into SAS that will not produce errors in the log, so they are not syntax errors, but most likely they are logic errors.
But maybe the definition of "syntax error" is the human user types in the wrong code ... ? I hope not, that's what it sounds like they are looking for. Is there anywhere in the class notes that defines "syntax error"?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @PaigeMiller ,
So we all agree that this specific problem is indeed a logic error. Maybe an incomplete copy-paste-adapt step in the book.
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Anne_A , I took the exam early this year. I think you don't have to worry about theoretical discussions whether it's a logic or syntax error. It's a practise exam. I you know how to do the coding covered by the content guide, you will be fine.
Best Luck anyway.
Best
Markus
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
One thing to consider, besides basic mean , is that when you use
(number1 + number2 + number3)
The result will be missing if any of the 3 variables have a missing value.
Consider this code. Run it and compare the results of the two Vmean variables.
data example; input v1 - v3; /* function mean*/ vmean1= mean(v1,v2,v3); /* manual calculation for mean*/ vmean2= (v1 + v2 + v3) / 3; datalines; 1 2 3 1 2 . . . . ;
So which construct you might use, function vs manual calculation, may depend on the need of your code.