BookmarkSubscribeRSS Feed
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;
proc print data=output27 (firstobs=100 obs=100);
var employee_id;

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?

Fluorite | Level 6

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

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: 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.

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?


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?
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.



Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.


Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 


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.

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
  • 6 replies
  • 4 in conversation