Click on the Comments to view the Answers

Wednesday, January 27, 2010

Base 55

The following SAS program is submitted:

proc sort data=work.employee;
by descending fname;

proc sort data=work.salary;
by descending fname;

data work.empdata;
merge work.employee work.salary;
by fname;
run;

Which one of the following statements explains why the program failed execution?

A. The SORT procedures contain invalid syntax.
B. The merged data sets are not permanent SAS data sets.
C. The data sets were not merged in the order by which they were sorted.
D. The RUN statements were omitted after each of the SORT procedures.

5 comments:

SASGuru said...

Answer C
data employee;
input fname $ age;
cards;
bruce 30
dan 40
;
run;

data salary;
input fname $ sal;
cards;
bruce 3000
dan 40000
;
run;

proc sort data=work.employee;
by descending fname;

proc sort data=work.salary;
by descending fname;

data work.empdata;
merge work.employee work.salary;
by fname;
run;


ERROR: BY variables are not properly sorted on data set WORK.EMPLOYEE.
fname=dan age=40 sal=40000 FIRST.fname=1 LAST.fname=1 _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 2 observations read from the data set WORK.EMPLOYEE.
NOTE: There were 2 observations read from the data set WORK.SALARY.
WARNING: The data set WORK.EMPDATA may be incomplete. When this step was stopped there were 0
observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.07 seconds
cpu time 0.01 seconds

Unknown said...

can you pls explain what would be the right way to merge?

Geoff said...

You sorted in descending order (the sort procedures will work fine because they encounter another step, messy programming, but it works). Then you tried to merge in ascending order.

Unknown said...

To solve the problem 2 alternatives:
1.
proc sort data=work.employee;
by descending fname;

proc sort data=work.salary;
by descending fname;

data work.empdata;
merge work.employee work.salary;
by descending fname;
run;

other

2.
proc sort data=work.employee;
by fname;

proc sort data=work.salary;
by fname;

data work.empdata;
merge work.employee work.salary;
by fname;
run;

Dutchy said...

C
Remember that this is also not good
proc sort data=work.employee;
by ASCENDING fname;

Becaise Ascending is not a reserved SAS word, so is seen as a variable.

If sorted in Ascending, then do not mention ascending, because it is the default.

Post a Comment



Technology Top Blogs On our way to 1,000,000 rss feeds - millionrss.com Hihera.com Blog Directory - OnToplist.com blogarama - the blog directory Blog Directory
Disclaimer

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Other brand and product names are trademarks of their respective companies.

This blog is not responsible for any kind of copyright violation. This blog just collects the links hosted or posted by other servers/people/search engines.The creator of this page or the ISP(s) hosting any content on this site take no responsibility for the way you use the information provided on this site.If anybody has any copyright claim on it and doesn’t wish the information provided to be shown on our site, please do respond to this email. We shall remove them off immediately. Any inconvenience is regretted. Please do mention your exact grievance/problems with respect to certain third party links. We assure you that appropriate action will be taken off. Thank you