You are analyzing a dataset with variables 'CUSTOMER_NAME', 'ORDER DATE', and 'ORDER VALUE'. You need to create a new variable 'ORDER DAY' that extracts the day of the week from 'ORDER DATE' (e.g., 'Monday', 'Tuesday', etc.). Which of the following SAS code snippets will accomplish this task correctly?
Correct Answer: C
The correct answer is C. The PUT function with the WEEKDATE. format is used to convert a date value to a day ofthe week in textual format (e.g., 'Monday', 'Tuesday', etc.). Option A, DAY function, extracts the day of the month, not the day of the week. Option B, WEEKDAY function, returns a numeric value representing the day of the week (1-7). Option D, while using WEEKDATE format, applies an unnecessary upcase function. Option E, SCAN function, tries to extract the first word from ORDER DATE assuming its a string, which may not be the intended behavior in this scenario. Understanding how date formats work and utilizing functions specifically designed for date manipulations is crucial for working with date variables in SAS.
A00-215 Exam Question 117
You have a SAS dataset named 'SALES' with variables 'CUSTOMER D', 'PRODUCT NAME', and 'SALES AMOUNT'. You want to export this dataset to a CSV file named 'sales data.csv', excluding the 'CUSTOMER ID' variable. Which PROC EXPORT statement will achieve this?
Correct Answer: C
The correct option is C. PROC EXPORT with the 'outlib' option allows specifying a dataset library to export data from. ensures that the 'CUSTOMER_ID' variable is excluded from the exported CSV file. Options A, B, and D are incorrect as they do not explicitly exclude the 'CUSTOMER_ID' variable. Option E renames the variable but does not exclude it from the export.
A00-215 Exam Question 118
Consider a dataset 'Sales' with variables 'Region', 'Product', and 'Sales_Amount'. You need to create a new dataset 'Summary' that reports the total sales for each region and product combination, but only for regions where the total sales exceed $10,000. Which SAS code would you use to achieve this?
Correct Answer: E
The correct answer is E. The code uses the BY statement to group the sales data by Region and Product. The function calculates the total sales for each group. The OUTPUT statement is then executed only if the sum is greater than 10,000, effectively filtering out regions with total sales below this threshold. Options A and B are incorrect because they do not use the correct function to calculate the total sales for each region-product combination. Option C is incorrect because it only checks for the last record in each region. Option D is incorrect because it only checks for the first record in each region. This scenario demonstrates how to use the OUTPUT statement in conjunction with BY group processing and aggregate functions to create a summary dataset based on specific conditions. It requires understanding the correct function and the use of group processing for data aggregation.
A00-215 Exam Question 119
You have a dataset with a variable 'Age' representing customer ages in years. You want to present this data in a report with age categories like Young Adult' (18-25), 'Adult' (26-45), 'Middle-Aged' (46-65), and 'Senior' (66+). Which of the following approaches is the most effective for applying the correct age category label using the FORMAT statement for temporary attributes?
Correct Answer: C
The most effective approach is to create a custom format using a macro that dynamically defines the age category based on the 'Age' value. This allows for easy modification of the age ranges and category labels without changing the main program logic. While other methods like separate FORMAT statements or nested IF statements are possible, they lack flexibility and can become cumbersome with multiple categories. Creating a permanent format in PROC FORMAT is suitable for consistent age categorization across multiple reports, but it requires a separate step and may not be ideal for changing age categories. Using a SAS data step with IF-THEN/ELSE statements is another viable option, but it adds an extra step to the data processing. Therefore, option C, using a custom format with a macro, offers the best combination of efficiency and flexibility.
A00-215 Exam Question 120
You have a dataset 'ORDERS' with variables: 'Order ID', 'Product', 'Quantity', 'Price', 'Customer_lD', 'Order Date'. You want to create a new dataset 'ORDER SUMMARY' that includes only the variables 'Product', 'Quantity', and 'Price' for orders placed in 2022. Additionally, you need to create a new variable named 'Total_Value' which is the product of 'Quantity' and 'Price'. Which code snippet achieves this correctly?
Correct Answer: B,D
Both options and are correct. They both filter for orders placed in 2022 using 'if year(Order_Date) = 2022 , then the desired variables ('Product', 'Quantity', 'Price') and calculate 'Total_Value' using 'Total _ Value = Quantity , Price' - They then use an -output' statement within the 'do' loop to create the new dataset 'ORDER _ SUMMARY'. Option A is incorrect because it calculates 'Total_Value' for all observations, regardless of the year, and the 'keep' statement is not within a 'do' loop, so 'Total_Value' might not be included in the output. Option C is incorrect because it tries to 'keep' a non-existing variable 'Total _ Value' before it's calculated. Option E is incorrect because it tries to 'keep' the variables after the 'Total_Value' is calculated, which won't include it in the final output The order of operations matters in this scenario.