Scenario 9

Code Solution

The solution listed below is one example of a program that could be used to accomplish each task within the scenario. Your code can be different, as long as it results in the same answers.
%let Location=USA;                                    /*#1*/
data work.flightempdata;                              /*#2*/
   set cert.empdata cert.empdatu cert.empdatu2;       /*#3*/
   where Country="&Location" and Salary >= 30000;     /*#4*/
run;
proc sort data=work.flightempdata;                    /*#5*/
   by descending Salary;
run;
proc export data=work.flightempdata                   /*#6*/
   outfile="C:certflightempdata.csv"
   dbms=csv
   replace;
run;
1 The %LET statement creates a macro variable named Location that stores the character variable value of USA.
2 The DATA step creates a new temporary data set named Work.Flightempdata.
3 The SET statement reads and concatenates the observations from the Cert.Empdata, Cert.Empdatu, and Cert.Empdatu2 data sets in that order.
4 The WHERE statement selects observations from the SAS data sets Cert.Empdata, Cert.Empdatu, and Cert.Empdatu2 that have a value for Country that is equal to the value of the macro variable &location The statement also selects observations that have a value of Salary greater than or equal to $30,000.
5 The PROC SORT step sorts the SAS data set Work.Flightempdata by the values of the variable Salary in descending order.
6 PROC EXPORT exports the SAS data set Work.Flightempdata to a comma-separated value file. The DATA= option identifies the input SAS data set, and the OUTFILE= option specifies the complete path and filename for the delimited external file. The DBMS = option specifies the type of data to export (in this case CSV), and the REPLACE option overwrites an existing file.
Output A2.13 PROC EXPORT Result: Flightempdata.csv
PROC EXPORT Result: Flightempdata.csv

Test Your Code Solution

  1. Correct Answer: $33,000
  2. Correct Answer: 290 – 300 bytes (any number within this range is an acceptable and correct answer)
Last updated: February 14, 2019
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset