ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 92

The following SAS program is submitted:
data work.report;
set work.sales_info;
if qtr(sales_date) ge 3;
run;
The SAS data set WORK.SALES_INFO has one observation for each month in the year 2000 and the variable SALES_DATE which
contains a SAS date value for each of the twelve months.
How many of the original twelve observations in WORK.SALES_INFO are written to the WORK.REPORT data set?
A. 2
B. 3
C. 6
D. 9
Click Comment link to get answer

24 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Anonymous7:14 AM

    if qtr(sales_date) ge 3;

    So the Ans is C

    ReplyDelete
  3. Anonymous1:18 PM

    can any one explain why it is C?
    thanks

    ReplyDelete
    Replies
    1. Anonymous7:16 PM

      Greater than and equal to 3rd quarter means 3rd quarter (jul, aug, sep) and 4th quarter of year (oct,nov,dec).

      answer is C i.e. 6 (July thru December).

      Delete
    2. How on earth are Biology students supposed to know that quarter 3 starts from Jun and not Sep?

      Delete
  4. Anonymous7:17 AM

    The qtr function returns a value of 1-4 depending upon which quarter of the year the sales_date lies. Of the twelve months, three will be assigned qtr(sales_date) equal to 3, and another three equal to 4, giving a total of 6 observations in the output.

    ReplyDelete
  5. Anonymous3:12 PM

    what we should know is qtr() is a function get the quarter in a year of the obs

    ReplyDelete
  6. Jahnavi12:35 PM

    QTR function returns a value of 1, 2, 3, or 4 from a SAS date value to indicate the quarter of the year in which a date value falls...here sales_date falls under 3rd quarter..and remaining 4th quarter gives 6 obs in output.

    ReplyDelete
  7. Anonymous7:49 AM

    Answer is D. 12 Months are divided into 4 qtrs.First 3 months are assigned a value of 1, next 3 months (april,may,june) a value of 2, (july,august,september) assigned a value of 3 and finally the last three months are given a value of 4.Inorder to meet the condition in if statement: the first 9 months are taken into consideration and hence answer is D.

    ReplyDelete
  8. Anonymous4:41 PM

    sorry , ans is c. look at ge 3 , so 3 months for equal to 3 and 3 months for greater than 3 will be considered...
    thanx

    ReplyDelete
  9. Answer is C. because 1 2 3 4 1 2 3 4 1 2 3 4 and number of 3's and 4's =6

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  10. Anonymous11:24 AM

    months = 123
    qrts = 3 4

    31
    32
    33
    41
    42
    43
    I think the iteration works this way? Please correct me.
    Sakar6o

    ReplyDelete
  11. Anonymous12:17 AM

    data test;
    ATTRIB MONTH FORMAT=MONYY7.;
    DO I = 1 TO 12;
    MONTH=INTNX ( 'month', '01DEC2011'D, i , 'SAMEDAY' );
    MONTH_QTR=QTR(MONTH);
    OUTPUT;
    END;
    run;

    proc print data=test;
    run;

    ReplyDelete
  12. Anonymous4:44 AM

    Jan 1
    Feb 1
    Mar 1
    Apr 2
    May 2
    Jun 2
    Jul 3
    Aug 3
    Sep 3
    Oct 4
    Nov 4
    Dec 4

    For QTR ge 3 there are six observations; hence answer is C 6

    ReplyDelete
  13. Anonymous7:39 PM

    The thing is the statement doesn't contain a then output. So you end up with 12 in Report. no?

    ReplyDelete
    Replies
    1. Anonymous7:42 PM

      as the original poster of this comment I see that I was wrong. please ignore

      Delete
  14. Anonymous2:13 AM

    can anybody explain easier why the answer is c? i can get what you guys are saying.

    ReplyDelete
    Replies
    1. Anonymous3:25 PM

      Qtr month SALES_DATE

      3 july anydate
      3 august anydate
      3 september anydate
      4 october anydate
      4 november anydate
      4 december anydate

      the output dataset will have values as per col 2, 3. I have indicatedd quarters for reference.
      since the date in question says if quarter is greater than or equal to 3, these 6 obs will be seen in otput.

      Delete
  15. Anonymous1:09 PM

    how is 3 greater than 3?

    ReplyDelete
    Replies
    1. Anonymous11:00 AM

      "ge" means greater than or equal to 3.

      Delete