You are working with a SAS dataset 'ORDERS' containing variables 'Order ID', 'Customer_lD', 'Product ID', 'Order _ Date', and 'Quantity'. You want to create a new dataset 'Active Orders' containing only orders placed in the current month, filtering out all other orders, and retaining all variables. Which code snippet will achieve this correctly?
Correct Answer: E
Option E correctly identifies orders within the current month. It uses the 'intnx' function to get the beginning ('b') and end ('e') of the current month and compares the 'Order_Date' to those values. Orders occurring on or after the beginning of the current month (inclusive) and before the end of the current month (exclusive) are considered 'Active_Orders'. Option A compares only the month without considering the year, which might include orders from a different year. Option B correctly compares the month and year, but is not as efficient as option E Option C uses 'intnx' to get the beginning of the month but does not consider the end, which might include orders from the next month. Option D uses 'intnx' to get the end of the month but does not consider the beginning, which might exclude orders from the current month.
A00-215 Exam Question 122
You have a SAS dataset called 'CUSTOMERS' with variables: 'CustomerlD', 'Name', 'City', 'State', 'Zip', 'Phone', 'Email'. You want to create a new dataset called 'CUSTOMER INFO' containing only the variables 'Name', 'City', and 'Email', but you also need to remove duplicate records based on the 'CustomerlD' variable. Which code snippet correctly accomplishes this?
Correct Answer: B
The correct answer is "B". This code uses a 'keep' statement to select the desired variables ('Name', 'City', 'Email'), then employs a 'by' statement to group observations by 'CustomerlD'. The 'if first-CustomerlD condition ensures only the first occurrence of each 'CustomerlD' is outputted, effectively removing duplicates. Option A is incorrect because it doesnt address duplicate records. Option C is incorrect because it uses the 'unique' statement incorrectly. The 'unique' statement is used to create unique values for a variable, not to remove duplicate records. Option D is incorrect because it uses the '_N_' variable, which represents the observation number, not the 'CustomerlD'. Option E is incorrect because the 'duplicated' function is not available in SAS SAS uses the 'first.CustomerlD' or 'last.CustomerlD' conditions within a 'by' statement for duplicate handling.
A00-215 Exam Question 123
You have a SAS dataset called 'EMPLOYEES' with variables 'EMPLOYEE ID', 'FIRST NAME', 'LAST NAME', 'DEPARTMENT', 'SALARY, 'HIRE DATE'. You need to create a new dataset called 'EMPLOYEES HIGH SALARY' containing only employees with salaries greater than $100,000, and you want to rename the 'SALARY' variable to 'HIGH SALARY'. Which code snippet correctly achieves this?
Correct Answer: D
Option D correctly combines the RENAME: option to change the variable name, the WHERE clause to filter based on salary, and the DROP= option to remove the 'HIRE_DATE' variable. The RENAME= option is used inside the SET statement to rename the 'SALARY' variable to 'HIGH_SALARY'. The WHERE clause filters the data by checking if the 'SALARY' variable is greater than 100000. Option A is incorrect because the RENAME= option should be placed inside the SET statement. Option B is incorrect because the HIGH_SALARY variable does not exist at the time of filtering. Option C is incorrect because it attempts to rename the variable inside an IF statement, which is not the right syntax Option E is incorrect as it does not drop the 'HIRE DATE' variable as requested in the scenario.
A00-215 Exam Question 124
You have a SAS dataset called 'SALES' with variables 'Region', 'Product', 'Sales', 'Quantity', and 'Date'. You want to create a new dataset called 'Top_Sales' containing only the 'Region', 'Product', and 'Sales' variables for the top 10 regions with the highest total sales. Which code snippet would achieve this correctly?
Correct Answer: E
Option E is the correct solution. It first sorts the dataset 'SALES' by the total sales in descending order. Then, it creates a new dataset 'Top_Sales', using the sorted dataset 'SALES_Sorted', and outputs only the first 10 observations. Finally, it uses the 'keep' statement to select the desired variables 'Region', 'Product', and 'Sales'. Option A outputs only the first 10 observations without considering the total sales by region. Option B uses SQL to group by region and filter based on a condition related to the average sales, which is not what the requirement asked for. Option C is incorrect because it uses 'obs=10' which will limit the dataset to 10 observations, regardless of total sales. Option D uses 'drop' to remove the unwanted variables, but it does not sort by sales or limit the dataset to the top 10 regions.
A00-215 Exam Question 125
You are tasked with analyzing customer data, specifically identifying customers who have made more than 3 purchases in the last 6 months. You need to use the OUTPUT statement to create a new dataset containing only these high-frequency customers. Which code snippet would you use to achieve this?
Correct Answer: D
Option D is the correct answer. This code snippet effectively identifies and outputs high-frequency customers. It first filters transactions within the past six months using the intnx function. The do loop then increments a count variable for each purchase within the timeframe. If the count exceeds 3, the output statement writes the customer's information to the HighFrequencyCustomers dataset. The by customer_id statement ensures that the count is reset for each new customer. Option A is incorrect because it lacks the by statement, causing the count variable to accumulate across all customers. Option B is incorrect for the same reason as Option A - it doesn't reset the count variable for different customers. Option C is incorrect as it omits the do loop, leading to a single increment in the count variable, regardless of multiple purchases within the timeframe. Option E is incorrect because the final output statement within the by group will output all transactions within a customer's six-month period, not just those that qualify as high- frequency (count > 3).