BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
stippur
Obsidian | Level 7

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?

 
Answer : C. The qtr (quarter) values of each of the months (July through December) 7,8,9,10,11,12 is 3,3,3,4,4,4..Therefore 6 obs are included in the final dataset.
I do not understand the answer to this question.Can someone please explain?
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

The function QTR returns the calendar quarter from a SAS date value. Qtr 1 is Jan, Feb, Mar, Qtr 2 is Apr, May, June; Qtr3 is Jul, Aug, Sep and Qtr 4 is Oct, Nov Dec.

 

Since you only have one record with a date for each month Qtr is ge 3 for Jul through Dec.

The IF without a then is a subsetting if and only records where the if condition is true are kept in the output data set.

 

Does this answer your question? If not please expand on what is confusing.

View solution in original post

2 REPLIES 2
ballardw
Super User

The function QTR returns the calendar quarter from a SAS date value. Qtr 1 is Jan, Feb, Mar, Qtr 2 is Apr, May, June; Qtr3 is Jul, Aug, Sep and Qtr 4 is Oct, Nov Dec.

 

Since you only have one record with a date for each month Qtr is ge 3 for Jul through Dec.

The IF without a then is a subsetting if and only records where the if condition is true are kept in the output data set.

 

Does this answer your question? If not please expand on what is confusing.

stippur
Obsidian | Level 7

Thanks ballardw! Your explanation was very helpful.