BookmarkSubscribeRSS Feed
ChaoticSweets
Obsidian | Level 7

Hello, i am currently trying to score an 80 on the prac exam but SAS has been a bit difficult for me to catch on.

Currently, i am reviewing my practice exam answers. 
I will display my code and the assumed correct code. However, the answers are vague and don't show how I can get the answer. This code also heavily puzzled me initally at first. 

 

here is the prompt to create the code initally in the prac exam;

    • Step 1:
      • create a temporary data set, cleandata36.
      • In this data set, convert all group values to upper case.
      • Then keep only observations with group equal to 'A' or 'B'.
    • Step 2:
      • Determine the MEDIAN value for the Kilograms variable for each group (A,B) in the cleandata36 data set. Round MEDIAN to the nearest whole number.
    • Step 3:
      • create results.output36 from cleandata36
      • Ensure that all values for variable Kilograms are between 40 and 200, inclusively.
      • If the value is missing or out of range, replace the value with the MEDIAN Kilograms value for the respective group (A,B) calculated in step 2.

 

The question i'm struggling with is

"What is the MEAN Kilograms value for group=‘A’ in the results.output36 data set?"

and of course the same, but for group B. 

My code: 

data cleandata36;
     set cert.input36;
     Group=Upcase(group);
     if Group in ('A', 'B') then output;
run;

proc means data=cleandata36 median maxdec=0;
     class Group;
     var Kilograms;
run;

data results.output36;
     set cleam data36;
     if 40 < kilograms < 200 < then do;
     if Group = 'A' then kilograms=79;
     else Kilograms=89;
   end;
run;

Suggested correct code:

data work.cleandata36;
     set cert.input36;
     group=upcase(group);
     if group in ('A', 'B'); 
run;

proc means data=work.cleandata36 median;
     class group;
     var kilograms;
run;

data results.output36;
     set cleandata36;
     if Kilograms<30 or  Kilograms>200 then do;
     if group='A' then kilograms=79;
     else kilograms=89;
end;
run;

proc contents data=results.output36;
run;

The mean that I found that was also indicated in the correct answer was 79 for group A, and 89 for group B.

however, the answers given was 76.3 for group A, and 86.5 for group b. I can't find the median in the results nor output data. I'm not sure where to look. 

 

I'm assuming it's because of maxdec?...hopefully? if not, why? 

 

Please go easy on me with terminology/wording. 

Iam also actively looking for a tutor if anyone knows one or would like to help because again i am STRUGGLING with learning a lot of these. videos are more difficult than it is with someone that can answer my questions asap because there is so many. thank you haha. 

     

lastly if you are also studying for your exam, we got this! please send me a message and hopefully we can help each other. thank you for your time!

5 REPLIES 5
ballardw
Super User

One thing to look at: the requirement Ensure that all values for variable Kilograms are between 40 and 200, inclusively.

Inclusively means that 40 and 200 are in the output.

Your code

     if 40 < kilograms < 200 < then do;

Has a serious issue with the third <, which I suspect you did not run successfully , and the rest excludes 40 and 200. 

Your "then do" would change the values of kilograms in the specified range not the missing or out of range values to ALL of the supposedly kept values to the median

 

There may be a problem with the instructions and the suggested code. Your copy of the requirement says 40 to 200

but the suggested code is using 30 and 200 as boundaries. So either your instructions are not copied correctly or the suggested code is using a different set of boundaries. So double check that.

 

You haven't provided an example of the cert.input36 so there isn't a way to check exactly.

If you can write a data step with the actual values we can provide some more details. A data step with the values would look something like:

data have;
   input group $ kilograms;
datalines;
a  123
B  88
c  345
;

but with more lines to read.

 

Note: It is often a very good idea to provide the LOG of the code you used because it will show 1) what you actually submitted and 2) it often provides some of the answers, or details of the answers to questions about "why does my code not do the expected <something about the output goes here>  ?"

ChaoticSweets
Obsidian | Level 7
Thank you for responding!! I appreciate it a lot as well as how you broke it down.

I am trying to pull up the log results for both my answer and the correct answer, however sas virtual labs is not allowing my libref to work correctly all of a sudden so I'm going to have to respond to this again a little later today to figure it out.
Mark2010
SAS Employee

@ChaoticSweets 

 

Just a note on preparation process and some insights that we have learned over time. It appears to me from this thread that you are using the practice exam early in your preparation process as a method to 'learn SAS.' I would caution against this. Rather, I would recommend using the Exam Content Guide, the recommended training courses, the exam prep guide, and time coding in SAS to 'learn SAS.'  Then, once you have gained a solid understanding of SAS programming, then use the practice exam to check that you are ready for the actual exam. Using the practice exam to guide your learning will cause you to (to use a statistical modeling term) 'overfit' your knowledge to the practice exam.

ChaoticSweets
Obsidian | Level 7
I was found out. haha. I appreciate the guidance! For me, I am just trying to find the best method of trying to learn since I don't really have an instructor and everything I am learning is self-paced. So I am using it in terms of attempting to utilize my notes some more and do thorough studying on terms that maybe I've missed out on, or if I need to go back and relearn that specific subject I shall. Although, I could be doing it all wrong. It's been a while since I've had to study for anything in all honestly so I've lost touch.

Thank you!
ChaoticSweets
Obsidian | Level 7
I was not able to get the log, however both were ran without issues and none of them affected the median value that I was provided. So I am still puzzled as to how the answers given are different.

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
3 ways to show off your SAS skills

 

Why Get SAS Certified.jpg

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
  • 763 views
  • 0 likes
  • 3 in conversation