BookmarkSubscribeRSS Feed
Uma_Devi
Fluorite | Level 6

The following the problem from the free model test paper of Base SAS certification exam and the code I wrote.The answer I get is not tallying with the right answer given:

This project will use data set cert.input27. At any time, you may save your program as program27 in cert\programs. You will use this program in the next project.
Write a SAS program that will:
o Create output data set results.output27a as a subset of cert.input27 where the country variable's value is "US" (any variation of case, such as US or us).
o Sort results.output27a:
 first by the variable state in ascending order
 then by Postal_Code in descending order
 and finally by employee_ID in ascending order.
Run the program and use the results to answer the question below.

1.What is the value of Employee_ID for observation 100 in results.output27a?
Right Answer given is : 120781  My answer is 121030. I checked for the employee_id 120781. It is not  there in the input27 dataset. 

can you kindly explain.

The code I wrote :

Proc sort data = cert.input27 out= output27;
where upcase(country)='US';
by state descending postal_code employee_id;
run;
proc print data=output27 (firstobs=100 obs=100);
var employee_id;
run;

6 REPLIES 6
ballardw
Super User

Without the original Cert.Input27 can't say.

Could be a number of things: Different input data, different version of an answer key for the data provided, typo, some where you modified the Cert.Input27 data set prior to this exercise. Do you have version information for this practice and the key?

 

Did you check to see if any of the State values have different case?

Uma_Devi
Fluorite | Level 6

Can I send you the input dataset? No all the observations had upper case observations in the country variable. 

ballardw
Super User

@Uma_Devi wrote:

Can I send you the input dataset? No all the observations had upper case observations in the country variable. 


Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

From the code you show the only other concern the Country variable might have is leading spaces.

I asked about whether the State variable might also have separate case because it is used in the Proc Sort code (I am assuming the other variables were numeric in the sort By statement). If a State has values like "AK" "Ak" and "ak" the sort on state could have a different than expected sort order.

 

Version of the documents and data is important because if the answer key is for one version and the data you are using is from a different one than I would expect differences. Also, someone here may recognize that there was a problem with a specific release.

Tom
Super User Tom
Super User

If the value they say is the right answer is not even in the input data then then input data is not what the question assumed it was.

 

Is it possible a mistake was made in creating the input data?

 

Uma_Devi
Fluorite | Level 6
I shall download the dataset again and try. If it is the same result as I get can I presume that the dataset used while giving the result in the exam is different from the one that is available now?
s_lassen
Meteorite | Level 14

I think the one error you made is that you did not save the generated data as RESULTS.OUTPUT27, but as WORK.OUTPUT27.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1084 views
  • 0 likes
  • 4 in conversation