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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
MarkusWeick
Barite | Level 11

Hi @Anne_A,

without having more context, I would assume a logic error.

Best

Markus

Please keep the community friendly.
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

View solution in original post

6 REPLIES 6
MarkusWeick
Barite | Level 11

Hi @Anne_A,

without having more context, I would assume a logic error.

Best

Markus

Please keep the community friendly.
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
Anne_A
Quartz | Level 8

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.

 

Screenshot1.jpgScreenshot2.jpg

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.

PaigeMiller
Diamond | Level 26

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
Anne_A
Quartz | Level 8

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.

MarkusWeick
Barite | Level 11

@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

Please keep the community friendly.
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
ballardw
Super User

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.

 

 

Welcome to the Certification Community

 

This is a knowledge-sharing community for SAS Certified Professionals and anyone who wants to learn more about becoming SAS Certified. Ask questions and get answers fast. Share with others who are interested in certification and who are studying for certifications.To get the most from your community experience, use these getting-started resources:

Community Do's and Don'ts
How to add SAS syntax to your post
How to get fast, helpful answers

 

Why Get SAS Certified.jpg

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1458 views
  • 5 likes
  • 4 in conversation