23.
The SAS data set ONE consists of five million observations and has 25 variables.
Which one of the following SAS programs successfully creates three new variables TOTREV, TOTCOST, and PROFIT and requires the least CPU time to be processed?
a.
data two;
set one;
totrev sum(price * quantity);
totcost = sum(fixed,variable);
profit = sum(totrev,totcost);
if totrev> 1000;
run;
b.
data two;
set one;
totrev = sum(price * quantity);
if totrev> 1000;
totcost = sum(fixed,variable);
profit = sum(totrev,totcost);
run;
c.
data two;
set one;
totrev = sum(price * quantity);
where totrev> 1000;
totcost = sum(fixed,variable);
profit = sum(totrev,totcost);
run;
d.
data two;
set one; where totrev> 1000;
totrev = sum(price * quantity);
totcost = sum(fixed,variable);
profit = sum(totrev,totcost);
run;
정답: B
[풀이]
if문은 모든 데이터를 평가 한 다음 올바른 데이터를 선택하는게 아니라 correct 데이터를 선택해 효율적으로 cpu time은 작아지는것입니다.
a는 if 조건에 결과가 없는 올바르지 않은 코드입니다.
24. Given the following SAS data set ONE:
ONE
COUNTRY CITY VISIT
USA BOSTON 10
UK LONDON 5
USA DALLAS 10
UK MARLOW 10
USA BOSTON 20
UK LONDON 15
USA DALLAS 10
The following SAS program is submitted:
proc sql;
select country, city, sum(visit) as TOTAL
from one group by country, city order by country, total desc;
quit;
Which one of the following reports is generated?
A.
COUNTRY CITY TOTAL
UK MARLOW 10
UK LONDON 20
USA BOSTON 50
USA DALLAS 20
B.
COUNTRY CITY TOTAL
UK LONDON 20
UK MARLOW 10
USA BOSTON 50
USA DALLAS 20
C.
COUNTRY CITY TOTAL
USA BOSTON 50
D.
COUNTRY CITY TOTAL
UK MARLOW 10
UK LONDON 20
USA DALLAS 20
USA BOSTON 50
[정답] B
[풀이]
proc sql;
select country, city, sum(visit) as TOTAL
from one group by country, city order by country, total desc;
quit;
group by xxx : 칼럼을 xxx 기준으로 나눠서 연산을 수행.
order by xxx : 칼럼을 xxx를 오름차순으로 데이터를 정렬합니다.
*여기서 B의 USA- BOSTON-30으로 바꿔야 합니다.
25. Given the following SAS data sets ONE and TWO:
ONE
NUM CHAR1
1 A
2 B
4 D
TWO
NUM CHAR2
2 X
3 Y
5 V
The following SAS program is submitted creating the output table THREE:
data three;
set one two;
run;
THREE
NUM CHAR1 CHAR2
1 A
2 B
4 D
2 X
3 Y
5 V
Which one of the following SQL programs creates an equivalent SAS data set THREE?
A.
proc sql;
create table three as select * from one outer union corr select * from two; quit;
B.
proc sql;
create table three as select * from one outer union select * from two; quit;
C.
proc sql;
create table three as select * from one outer union select * quit;
D.
proc sql; create table three as select * from one union corr select * from two; quit;
*Set Operator Code
SELECT
UNION | OUTER JOIN | EXCEPT | INTERSECT
OUTER UNION에서 CORR MODIFIER
두 개의 SET에서 중복되는 변수는 하나의 열로 통합합니다.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.