data work.new; length word $7; amount = 4; if amount = 4 then word = 'FOUR'; else if amount = 7 then word = 'SEVEN'; else word = 'NONE!!!'; amount = 7; run;
Which one of the following represents the values of the AMOUNT and WORD variables?
1. amount word 7 FOUR 2. amount word 7 SEVEN 3. amount word 4 FOUR 4. amount word 4 ' ' (missing character value)
Correct Answer : 1 SAS reads the first amount 4 and we get the fist obs 4 four as the sas reads amount = 7 then output, then it replaces the amount 4 to 7. we get a output like this. 7 four
Question :
The SAS data set EMPLOYEE_INFO is listed below:
IDNumber Expenses 2542 100.00 3612 133.15 2198 234.34 2198 111.12 The following SAS program is submitted: proc sort data = employee_info;
run; Which one of the following BY statements completes the program and sorts the data sequentially by descending expense values within each descending IDNUMBER value? 1. by descending IDNumber Expenses; 2. by (IDNumber Expenses) descending; 3. by IDNumber descending Expenses descending; 4. by descending IDNumber descending Expenses;
Correct Answer : 4
For each variable we have to mention descending keyword before variable name. sort variables.
ascending is default
so Descending Var1 Descending var2
Question :
The SAS data set QTR1_REVENUE is listed below:
destination revenue YYZ 53634 FRA 62129 FRA 75962 RDU 76254 YYZ 82174 The following SAS program is submitted: proc sort data = qtr1_revenue; by destination descending revenue; run;
Which one of the following represents the first observation in the output data set? 1. destination revenue YYZ 82174 2. destination revenue YYZ 53634 3. destination revenue FRA 62129 4. destination revenue FRA 75962
Correct Answer : 4 Ascending destionaiton, descdending revenue. The word descending only modifies the variable directly after it.
so "by destination descending revenue" causes destination to be in ascending order (A,B,C,D,E,F,G)and revenue will be in descending order (9,8,7,6,5,4,3).