ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 100

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.
Click Comment link to get answer

30 comments:

  1. Anonymous8:07 AM

    C. The data sets were not merged in the order by which they were sorted.

    ReplyDelete
  2. Anonymous3:19 PM

    Is it necessory to merge two or more data sets in a say order as they sorted?

    ReplyDelete
  3. Anonymous12:07 PM

    ?
    The two datasets were sorted pre merge statement in the question, all by decending of fname. I would say if it is not working, it would be fname may not exist for one of the dataset. A is my answer.

    ReplyDelete
  4. Anonymous8:18 PM

    anns

    ReplyDelete
  5. Anonymous12:40 AM

    Correct Answer: C
    You should have the DESCENDING option in the BY statement in both the PROC SORT steps and the DATA STEP. If you omit the DESCENDING option in the DATA STEP, you denerate error messages about improperly sorted BY Variable.

    ReplyDelete
  6. Anonymous12:53 AM

    Correct Answer: C
    100% correct
    You need to have the DESCENDING option in the BY statements in both the PROC SORT steps and the DATA step. If you omit the DESCENDING option in the DATA step in the BY statement, you generate error messages about improperly sorted BY Variables.

    ReplyDelete
  7. Anonymous2:27 PM

    so how do we know what the absolute correct answer is?

    ReplyDelete
  8. PROC SORT DATA=states;
    BY state_name;
    PROC SORT DATA=vehicles;
    BY state_name;
    DATA widedata;
    MERGE states vehicles;
    BY state_name;
    RUN;

    C is tehe good answer

    ReplyDelete
  9. Anonymous11:37 AM

    Thank you for the examples, they are great...this is a bit off the point but if someone could clarify -

    merge work.employee
    work.salary;
    by fname;

    is the new data set work empdata going to merge the two datasets and sort them in ascending order now by fname? I thought the reason for going through the proc sort by descending fname for each separate data set as to avoid the default sort?

    ReplyDelete
  10. Anonymous12:13 PM

    I believe it's B and D.

    A not, syntax is correct
    C not, the datasets weren't merged because of the missing descending at the by statement of the datastep (all by statements must have the same order)

    B because employee and salary are in work and
    D if run is missing, the next data or proc step will determine the end of the previous step and run will be omitted

    ReplyDelete
  11. Anonymous4:06 PM

    ERROR: BY variables are not properly sorted on data set WORK.AIR.
    DATE=01DEC1960 AMOUNT=. AIR=432 FIRST.DATE=1 LAST.DATE=1 _ERROR_=1 _N_=1

    The above is the error when I ran the code..so its D

    ReplyDelete
    Replies
    1. Jenine2:33 PM

      Sorry but your error message would indicate the correct answer is C

      (which is certainly is!)

      Delete
  12. Anonymous4:25 PM

    data banks;
    input num;
    datalines;
    1
    2
    3
    4
    5
    ;
    run;
    data banks2;
    input num x $;
    datalines;
    5 a
    4 b
    3 c
    2 d
    1 e
    ;
    run;
    proc sort data=banks;
    by descending num;
    run;
    proc sort data=banks2;
    by descending num;
    run;
    data banks3;
    merge banks banks2;
    by num;
    run;

    log

    ERROR: BY variables are not properly sorted on data set WORK.BANKS.
    num=5 x=a FIRST.num=1 LAST.num=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.BANKS.
    NOTE: There were 2 observations read from the data set WORK.BANKS2.
    WARNING: The data set WORK.BANKS3 may be incomplete. When this step was stopped there were 0
    observations and 2 variables

    ans is c as it merges when u insert descending in the data step

    ReplyDelete
  13. Anonymous6:41 AM

    you really dont need to input this into SAS. data step needs to have the by statement in the same exact manner as it was sorted out. in this case you have to use descending.
    ans is c

    ReplyDelete
  14. answer is definitely C. u dont need run at the end and it needs to be sorted out in the same order.

    ReplyDelete
  15. Anonymous1:11 PM

    Folks , Even the data has in shorted form and sorted properly , give the same error.

    That means we are missing something in the data statements or proc statement.
    Look at this data set.

    data bank1;
    input num y $;
    datalines;
    1 t
    2 u
    3 v
    ;
    run;

    data banks2;
    input num x $;
    datalines;
    1 a
    2 b
    3 c
    ;
    run;
    proc sort data=bank1;
    by descending num;
    run;
    proc sort data=banks2;
    by descending num;
    run;
    data banks3;
    merge bank1 banks2;
    by num;
    run;
    proc print data=bank3;
    run;

    I got the same error. So what is the reason it is giving us that error message,
    W need to find out that then we will be ready for the exam. We are getting answer just running a sas program. But in exam we have to use our head and the logic. How we going to get it and what is it, giving us error message.

    ReplyDelete
  16. Anonymous8:56 AM

    In merge if you choose to sort by descending then you must use descending with merge statement otherwise it will not merge because of reason ( C ).
    It does not matter if you sort by ascending order.

    ReplyDelete
  17. The 2 proc sorts arrange in desc order...but the merge is in asc order...so the merge will fail ANS C

    ReplyDelete
  18. Anonymous9:33 AM

    Base SAS prep Guide:
    "General form, basic DATA step for match-merging:
    DATA output-SAS-data-set;
    MERGE SAS-data-set-1 SAS-data-set-2;
    BY variable(s);
    RUN;
    DESCENDING indicates that the input data sets are sorted in descending order (largest
    to smallest numerically, or reverse alphabetical for character variables) by the variable that is
    specified.
    Each input data set in the MERGE statement must be sorted in order of the values of the BY variable(s), or it must have an appropriate index. Each BY
    variable must have the same type in all data sets to be merged."

    So answer is C.

    ReplyDelete
  19. Anonymous9:40 AM

    typo correction :
    By descending variable(s).

    ReplyDelete
  20. SAS mentions I need a minimum of 70% correct to pass the exam, so is it ok if I mark 70% of the questions correct & 30% wrong, will I still be able to pass the test ????

    ReplyDelete
  21. thank you for all the explanations

    ReplyDelete
  22. For latest and updated SAS certification dumps in PDF format contact us at completeexamcollection@gmail.com

    Refer our blog for more details http://completeexamcollection.blogspot.in/2015/12/sas-certification-dumps.html

    ReplyDelete
  23. Anonymous11:22 AM

    C is 100 % right Answer.
    Because In Sort procedure data sorted in descending order . but descending keyword is missing while Merging the Data in By statement.

    Right Code :

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

    ReplyDelete
  24. Anonymous1:08 AM

    THanks

    ReplyDelete