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
This comment has been removed by the author.
ReplyDeleteC
ReplyDeleteif qtr(sales_date) ge 3;
ReplyDeleteSo the Ans is C
can any one explain why it is C?
ReplyDeletethanks
Greater than and equal to 3rd quarter means 3rd quarter (jul, aug, sep) and 4th quarter of year (oct,nov,dec).
Deleteanswer is C i.e. 6 (July thru December).
How on earth are Biology students supposed to know that quarter 3 starts from Jun and not Sep?
DeleteThe 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.
ReplyDeletewhat we should know is qtr() is a function get the quarter in a year of the obs
ReplyDeleteQTR 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.
ReplyDeleteAnswer 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.
ReplyDeletesorry , ans is c. look at ge 3 , so 3 months for equal to 3 and 3 months for greater than 3 will be considered...
ReplyDeletethanx
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
ReplyDeleteThis comment has been removed by the author.
Deletemonths = 123
ReplyDeleteqrts = 3 4
31
32
33
41
42
43
I think the iteration works this way? Please correct me.
Sakar6o
data test;
ReplyDeleteATTRIB 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;
Jan 1
ReplyDeleteFeb 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
ok... got it now!
DeleteThe thing is the statement doesn't contain a then output. So you end up with 12 in Report. no?
ReplyDeleteas the original poster of this comment I see that I was wrong. please ignore
Deletecan anybody explain easier why the answer is c? i can get what you guys are saying.
ReplyDeleteQtr month SALES_DATE
Delete3 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.
how is 3 greater than 3?
ReplyDelete"ge" means greater than or equal to 3.
DeleteC
ReplyDelete