BookmarkSubscribeRSS Feed
Teeleaf
Fluorite | Level 6

For the 1st "Test your code" question in scenario case 10:

   1. What is the number of observations where the variable Type is Sedan?

 

The answer is showing obs:262.

However, I have obs:405.

 

Is it because the source data updated or I missed any step?

 

Thanks in advanced.

5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi: Can you provide some context for the question. Where did the question come from? Are you working in Programming 1? If so, what Lesson is the question in? Are you working on something else? Homework? Practice exam? If the Practice Exam, is it the Pearson VUE Practice Exam or the SAS Practice Exam. What is the WHOLE question? There must be code that you wrote to derive your answer? Was there starter code or suggested code? What was that code?

Without knowing the name of the data set you're using, it could be SASHELP.CARS, it could be some other file -- it's hard to provide any meaningful feedback.

Cynthia
Teeleaf
Fluorite | Level 6

Thanks so much all !!

I think I misunderstood the question.

I think the question is asking the total number of observations where the variable Type is Sedan.

Not the number of observations where the variable type is sedan that With Average MPG Over 40.

 

To be more detail, i will provide the question and the code from answer key below.

 

Here is the question:

Open the ehs02 program from the EHS folder and correct the errors in the program below.
Example Code 2 ehs02 Program: Fix the Errors

      work.mycars;
           set sashelp.cars;
           AvgMPG=mean(mpg_city, mpg_highway);
     run;
     title 'Cars With Average MPG Over 40';
     proc print data=work.mycars
           var make model type avgmpg;
           where AvgMPG>40;
     run;
     title 'Average MPG by Car Type';
     proc means data=work.mycars avg min max maxdec=1;
           var avgmpg;
           class type;
     run;
     title;

 

Test Your Code:
1. What is the number of observations where the variable Type is Sedan?
2. How many observations are printed to the report titled, “Cars With Average MPG Over 40”?

Objectives Accomplished:
• Identify the characteristics of SAS statements.
• Define SAS syntax rules and identify common syntax errors such as misspelled keywords, unmatched quotation marks,
missing semicolons, and invalid options.
• Use the log to help diagnose syntax errors in a given program.

---------------------------------------------------------------------------------------------

 

below is the code from the answer keys:

     data work.mycars;
           set sashelp.cars;
           AvgMPG=mean(mpg_city, mpg_highway);
     run;
     title "Cars with Average MPG Over 40";
     proc print data=work.mycars;
          var make model type avgmpg;
          where AvgMPG>40;
     run;
     title "Average MPG by Car Type";
     proc means data=work.mycars mean min max maxdec=1;
          var avgmpg;
          class type;
    run;

    title;

andreas_lds
Jade | Level 19

@Teeleaf wrote:

For the 1st "Test your code" question in scenario case 10:

   1. What is the number of observations where the variable Type is Sedan?

 

The answer is showing obs:262.

However, I have obs:405.

 

Is it because the source data updated or I missed any step?

 

Thanks in advanced.


Then, most likely something is wrong with your code. In sashelp.cars are only 262 obs with type = "Sedan".

ballardw
Super User

And only 428 total observations in SASHELP.CARS.

 

At a minimum You need to show 1) any code used to create the data set you summarized and 2) the code used for the summary.

 

 

Teeleaf
Fluorite | Level 6

Thanks so much all !!

I think I misunderstood the question.

I think the question is asking the total number of observations where the variable Type is Sedan.

Not the number of observations where the variable type is sedan that With Average MPG Over 40.

 

To be more detail, i will provide the question and the code from answer key below.

 

Here is the question:

Open the ehs02 program from the EHS folder and correct the errors in the program below.
Example Code 2 ehs02 Program: Fix the Errors

      work.mycars;
           set sashelp.cars;
           AvgMPG=mean(mpg_city, mpg_highway);
     run;
     title 'Cars With Average MPG Over 40';
     proc print data=work.mycars
           var make model type avgmpg;
           where AvgMPG>40;
     run;
     title 'Average MPG by Car Type';
     proc means data=work.mycars avg min max maxdec=1;
           var avgmpg;
           class type;
     run;
     title;

 

Test Your Code:
1. What is the number of observations where the variable Type is Sedan?
2. How many observations are printed to the report titled, “Cars With Average MPG Over 40”?

Objectives Accomplished:
• Identify the characteristics of SAS statements.
• Define SAS syntax rules and identify common syntax errors such as misspelled keywords, unmatched quotation marks,
missing semicolons, and invalid options.
• Use the log to help diagnose syntax errors in a given program.

---------------------------------------------------------------------------------------------

 

below is the code from the answer keys:

     data work.mycars;
           set sashelp.cars;
           AvgMPG=mean(mpg_city, mpg_highway);
     run;
     title "Cars with Average MPG Over 40";
     proc print data=work.mycars;
          var make model type avgmpg;
          where AvgMPG>40;
     run;
     title "Average MPG by Car Type";
     proc means data=work.mycars mean min max maxdec=1;
          var avgmpg;
          class type;
    run;

    title;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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