Syntax Issue : As you need to create new dataset than it should be in Data step. Hence, option 2 is out because it is not the correct one. In data step it has given course2017.
Another is logical things : As you can see while creating data it also has some logic based on column DURATION and create a new column named TOTALFEE. If you want to drop DURRATION column in the output that is fine, but you also want it for calculation. Hence, you need to keep it for the calculation. In this case only option 2 is correct, which keep as well as drop this column.
Question : You have written following program using By statement
data courses2017_1; set courses; by course_name; if first.course_name then TOTALFEE=0; TOTALFEE+FEE; if last.course_name; run;
Which of the following statements are correct?
A. Dataset courses has to be sorted by course_name B. There two variables will be created FIRST and LAST for the course_name variable. C. FIRST and LAST are the two variables in each By group which represent first and last observation of that group. D. FIRST and LAST variable will be stored with the dataset courses2017_1.
Correct Answer : Get Lastest Questions and Answer : Explanation: When you create a new dataset using By statement than original data set must be sorted by the columns which are used in the by statement.
Another important thing is that when you use By statement in set data step than two variables will be created FIRST and LAST which represent first and last observation of that group created using By statement. However, they are temporary and will not be stored with the dataset.
Question : You have been given below SAS program what would be the result when you execute it?
data course2017; input COURSE_ID 1-3 COURSE_NAME$ 5-20 LOCATION$ 22-30 FEE 32-35 DATE$ 36-47 DURATION 48-50; obsnum=5; stop; datalines; 100 SAS MUMBAI 5000 01-JAN-2017 30 101 MACHINE PUNE 7000 01-FEB-2017 24 102 MACHINE PUNE 7000 01-MAR-2017 24 103 HADOOP BANGLORE 8000 01-APR-2017 40 104 HADOOP BANGLORE 9000 01-MAY-2017 30 105 SPARK CHENNAI 7000 01-JUN-2017 32 106 SPARK CHENNAI 6500 01-JUL-2017 30 107 SPARK CHENNAI 6500 01-AUG-2017 30 108 HADOOP AHMEDABAD 5000 01-SEP-2017 24 109 SAS MUMBAI 5000 01-OCT-2017 24 110 SAS JODHPUR 5000 01-NOV-2017 24 ; run;
1. It will be generating 5 observation in the output
Correct Answer : Get Lastest Questions and Answer : Explanation: In the given program you need to understand the stop statement. As soon as stop statement is found SAS program will be stopped for further execution. And to generate the output whatever in the dataset till the stop statement, it require output statement. As there is no output statement , hence it will generate empty results.