본문 바로가기

자격증/SAS BASE

SAS Crambible 103 ~ 139.

https://normalpdf.tistory.com/82

 

SAS 관련 정리

1. 실행 단축키 : F3 2. 주석 달기 : Ctrl + / 3. Footnote statment : output 에서 아랫부분의 데이터와 상관없이 설정한 문자값을 보여주는 명령어 footnote1 'Sales Report for Last Month' footnote2 'Selected Products Only' foo

normalpdf.tistory.com

 

1~102 번까지는 위 게시물에 정리되어 있습니다.

 

 

 

 

103. Input 으로 데이터 불러오기 : datalines;

 

The following SAS program is submitted:

 

data WORK.TEST;

  drop City;

  infile datalines;

  input 

  Name $ 1-14 /   -----------→  변수명을 선언해 준다.

  Address $ 1-14 /

  City $ 1-12 ;

  if City="New York' then input @1 State $2.;

  else input;

 

  datalines;

  Joe Conley

  123 Main St.

  Janescile

  WI     -----------→  4 줄이 한 사람을 의미

  Jane Ngyuen

  555 Alpha Ave.

  New York

  NY

  Jennifer Jason

  666 Mt. Diablo

  Eureka

  CA ;

 

 

Q. What will the data set WORK.TEST contain?    ★

 

Name Address State

Joe Conley 123 Main St.

Jane Ngyuen 555 Alpha Ave. NY

Jennifer Jason 666 Mt.Diablo


129. INPUT 으로 Raw 데이터 읽기

The contents of the raw data file SIZE are listed below:

---------10---------20---------30
72 95
 
The following SAS program is submitted:
 
data test;
infile 'size';
input @1 height 2. @4 weight 2;      -----------→  @4 weight 2 에 period (.) 이 빠진 경우
run;
 

Q. Which one of the following is the value of the variable WEIGHT in the output data set?  (2)

 

input @1 height 2. @4 weight 2;     input @1 height 2. @2 weight ;    (같은 의미)
  • 2번째부터 다 불러오는데 구분자 (space) 를 만나기 때문에 2에서 끊어진다.   ★

 

Height Weight
72 2

 

Q. 만약 Period (.) 이 빠지지 않았더라면?

 

input @1 height 2. @4 weight 2.;  

Height Weight
72 95

131. If - Then INPUT  으로 데이터 읽어오기

 

The contents of the raw data tile EMPLOYEE are listed below:

Ruth 39 11
Jose 32 22
Sue 30 33
John 40 44

 

The following SAS program is submitted:

 

data test;

  infile 'employee';

  input employee_name $1-4;

  if employee_name = "Sue" then input age 7-8;

  else input idnum 10-11;

run;

 

 

Q. Which one of the following values does the variable AGE contain when the name of the employee is "Sue"?    (40)

employee_name idnum age
Ruth 22  
Sue   40

 

 
 

Q. 만약 @ 가 있었다면?

data test;

  infile 'employee';

  input employee_name $1-4@ -----------→  해당 행에서 변수 정의를 이어서 해준다

  if employee_name = "Sue" then input age 7-8;

  else input idnum 10-11;

run;

 
Employee_name idnum age
Ruth 11  
Jose 22  
Sue   30
John 44  
 

 

 

 

 

 

 
 

104. SET 로 데이터 정렬 - 데이터를 세로로 연결

 

Given the SAS data set WORK.ONE :

Id Char1
111 A
158 B
329 C
644 D

the SAS data set WORK.TWO :

Id Char2
111 E
538 F
644 G

 

 
The following program is submitted:
 
data WORK.BOTH;
set WORK.ONE WORK.TWO;   -----------→  데이터를 세로로 붙인다.
by Id;
run;

 

(BY id 로 정렬하기 전)

Id Char1 Char2
111 A  
158 B  
329 C  
644 D  
111   E
538   F
644   G

 

(BY id 로 정렬)

Id Char1 Char2
111 A  
111   E
158 B  
329 C  
538   F
644 D  
644   G

 

 

Q. What is the first observation in SAS data set WORK.BOTH?

Id Char1 Char2
111 A  

 

 

 

 

 

 

105. mdy ( ) 함수 - 인수에 문자형과 숫자형이 같이 있는 경우

The following SAS program is submitted:

 

data WORK.DATE_INFO;

Day="01";  -----------→  문자형

Yr=1960;  -----------→  숫자형

X=mdy(Day,01,yr);    -----------→  month,day, year / 문자형 "01" 이 있어도 "01" 을 숫자형으로 변환하여 진행한다.

run;

 

 

Q. What is the value of the vatiable X?

   (The numeric value 0)

 

  • mdy(Day,01,yr) = mdy(01,01,1960) 
  • 그 날짜에 해당하는 수치적인 값을 내뱉는다.
  • 1960.01.01.  이므로 답은 0 이다 !!
  • ... -1
    1960.01.01 0
    1960.01.02 1

 

 

 

 

 

 

106. Array

 

The following SAS program is submitted:

 

data WORK.AUTHORS;

array Favorites {3} $ 8 ('Shakespeare', 'Heminhway', 'McCaffrey'); 

run;

 

 

 

Q. What is the value of the second variable in the dataset WORK.AUTHORS?

  (Heminhwa)

 

 

  • array Favorites {3} $ 8 ('Shakespeare', 'Heminhway', 'McCaffrey');   
  • array 의 이름 Favorites, 값은 총 3개, 문자형 변수이고 길이는 8
  •  
    Favorites1 Favorites2 Favorites3
    Shakespe Heminhwa McCaffre
  • array 안에 들어가는 변수의 이름이 없기 때문에 Favorites1~3 의 변수명을 갖는다.   

 

 

 

 

 

 

107. 일시적으로 label 을 교체하고 싶을 때

 

The SAS data set Fed.Banks contains a variable Open_Date

which has been assigned a permanent label of "Open Date".

 

 

Q. Which SAS program temporarily replaces the label "Open Date" with the label "Starting Date" in the output?   (B)

 

 

A. 

proc print data=SASUSER.HOUSES label;

label Open_date "Starting Date";

run;

 

 

B.

proc print data=SASUSER.HOUSES label;

label Open_date = "Starting Date";

run;

 

 

C.

proc print data=SASUSER.HOUSES;

label Open_date = "Starting Date";

run;

 

 

D.

proc print data=SASUSER.HOUSES;

Open_date "Starting Date";

run;

 

 

 

proc print data=데이터명 label;

    label 변수명 = '변경할 라벨명';

run; 

 

 

 

 

 

 

108. 결측과 대소관계 비교하기  - 무조건 참 !!

 

Consider the following data step:

 

data WORK.NEW;

 set WORK.OLD(keep=X);

   if X < 10 then X=1;

   else if X >= 10  AND X LT 20 the X=2; 

   else X=3;

run;

 

In filtering the values of the variable X in data set WORK.OLD,

 

Q. What value new value would be assigned to X if its original value was a missing value?

  (X would get a value of 1.)

 

 

  • original value 가 Missing Value 이므로 X < 10 에서 무조건 참이다 !!!   ★
  • 따라서 첫번째 조건문을 만족하여, X 값은 1이다.

 

 

 

 

 

 

109. PROC FORMAT - format 정의 시 period 필요없음

 

The following program is submitted:

 

proc format;  -----------→ Format 을 사용하여 사용자가 정의

  value salfmt.   -----------→  format 을 정의할 때는 포멧 이름만 적는다. period(.)은 사용 X

  0 <-50000 = 'Less than 50K'

  50000 - high = '50K or Greater';

  options fmterr nodate pageno=1;

  title 'Employee Report';

 

proc print data=work.employees noobs;

  var fullname salary hiredate;

  format salary salfmt.  firedate date9.;  -----------→ 포멧을 적용할 떄는 period(.)을 사용한다.

  label

  fullname='Name of Employee'

  salary='Annual Salary'

  hiredat='Date of Hire';

run;

 

 

 

Q. Why does the program fail?

    (The format name contains a period in the VALUE Statement.)

 

 

  1. The PAGENO options is invalid in the OPTIONS statement.
  2. The RUN statement is missing after the FORMAT procedure.   (X)   
  3. The format name contains a period in the VALUE Statement.
  4. The LABEL options is missing from the PROC PRINT statement.

 

 

 

 

 

 

 

111. input 으로 데이터 읽어오기 - dsd, @, missover

 

Given the following raw data records in TEXTFILE.TXT:

 

 

The following output is disired.

 

Obs Name Month Status Week1 Week2 Week3 Week4 Week5
1 John FEB Final $13 $25 $14 $27 .
2 John MAR Current $26 $17 $29 $11 $23
3 Tina FEB Final $15 $18 $12 $13 .
4 TIna MAR Current $29 $14 $19 $27 $20

 

 

Q. Which SAS program correctly procedures the desired output?   (C)

 

 

A.

data WORK.NUMBERS;

  length Name $4 Month $3 Status $7;

  infile 'TEXTFILE.TXT'  dsd;    -----------→  구분자 comma

  input Name $ Month $;   -----------→  @ 가 없어 첫번째 행만 나온다.

  if Month='FEB' then input Week1 Week2 Week3 Week4 Status $;

  else if Month='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $;

  format Week1-Week5 dollar6.;

run;

 

proc print data=WORK.NUMBERS;

run;

 

B.

data WORK.NUMBERS;

  length Name $4 Month $3 Status $7;

  infile 'TEXTFILE.TXT'  dlm=',', missover;  -----------→  dsd의 기능 =  dlm=',' +  missover

  input Name $ Month $;

  if Month='FEB' then input Week1 Week2 Week3 Week4 Status $;

  else if Month='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $;

  format Week1-Week5 dollar6.;

run;

 

proc print data=WORK.NUMBERS;

run;

 

C.

data WORK.NUMBERS;

  length Name $4 Month $3 Status $7;  -----------→ length 로 인해 Status 변수가 Week1-5 변수보다 앞에 나온다.

  infile 'TEXTFILE.TXT'  dlm=',';

  input Name $ Month $ @;  -----------→ 첫번째 행을 불러오고, 두번째 행, 세번째 행....이어서 불러온다.

  if Month='FEB' then input Week1 Week2 Week3 Week4 Status $;

  else if Month='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $;

  format Week1-Week5 dollar6.;

run;

 

proc print data=WORK.NUMBERS;

run;

 

  • @가 있어서 if 절에서 input 문을 만났을 때 다음 레코드로 넘어가지 않고 현재 레코드의 다음 데이터가 입력된다.

 

D.

data WORK.NUMBERS;

  length Name $4 Month $3 Status $7;

  infile 'TEXTFILE.TXT'  dsd @;   -----------→ infile 에는 @ 옵션을 사용할 수 없다 !!

  input Name $ Month $;

  if Month='FEB' then input Week1 Week2 Week3 Week4 Status $;

  else if Month='MAR' then input Week1 Week2 Week3 Week4 Week5 Status $;

  format Week1-Week5 dollar6.;

run;

 

proc print data=WORK.NUMBERS;

run;

 

 

 

 

 

 

113. Retain 이해 

 

The following SAS program is submitted:

 

data WORK.TOTAL_SALARY;

  retain Total;    -----------→ 초기치를 지정하지 않은 상태

  set WORK.SALARY;

  By Department;

  if First.Department then Total=0;

  Total= sum(Total,Wagerate);

  if Last.Department;

run;

 

 

Q. What is the initial value of the variable Total in the following program?   (MIssing)

 

  • Retain variable [initial_value]
  • 특별히 변수의 형태를 지정하지 않으면, Retain 명령문에 지정된 변수는 수치형 변수이다.
  • 문자형 변수를 지정하고 싶다면, 초기치를 지정하거나 / LENGTH 구문을 이용하여 변수의 길이를 사전에 지정해야 한다.
  • 변수의 초기치를 지정하지 않으면 결측이 초기치로 지정된다. 

126. Retain 과 Assignment statement 의 비교

 

Consider the following data step :

 

data WORK.TEST;

  set SASHELP.CLASS(obs=5);

  retain City 'Beverly Hills';

  State ='California';

run;

 

The comuted variables City and State have their values assigned using different methods,

A RETAIN statement and Assignment statement.

 

 

Q. Which statement regarding this program is true?

 

  • Both the RETAIN and assignment statement are being used to initialize new variables and are equally efficient. Method used is a matter of programmer preference.   (X)
  • City's value will be assigned one time, State's value 5 times.   (O)
  • assignment statement 로 할당한 것은 데이터의 개수만큼 할당된다.

 

 

 

 

 

114. Compile 

 

Consider the following data step:

 

data WORK.NEW;

  set WORK.OLD;

  Count + 1;

run;

 

 

The variable Count is created using a sum statement.

 

 

Q. What statement regarding this variable is true?

   (It is assigned a value 0 at compile time)

 

  1. It is assigned a value 0 when the data step begins execution.    (X)
  2. It is assigned a value of missing when the data step begins execution.   
  3. It is assigned a value 0 at compile time.   (O)
  4. It is assigned a value of missing at compile time.

 

 

 

 

 

116. 구분자 옵션 - dlm, dsd

 

Given the following raw data records:

The following output is desired:

 

 

Q. Which SAS program correctly reads in the raw data?    (D)

 

A.

data employees; 
infile 'C:\folders\mypath\cert\a.txt' dlm='*';    -----------→  두 번째 데이터가 안불러와진다.
input employee$ bdate : mmddyy10. years;
run;

proc print data=employees;
run;

 

B.

data employees; 
infile 'C:\folders\mypath\cert\a.txt' dsd='*';    -----------→ 문법 X
input employee$ bdate : mmddyy10. years;
run;

proc print data=employees;
run;

 

 

 

C.

data employees; 
infile 'C:\folders\mypath\cert\a.txt' dlm dsd;    -----------→ 문법 X
input employee$ bdate : mmddyy10. years;
run;

proc print data=employees;
run;

 

 

 

D.

data employees; 
infile 'C:\folders\mypath\cert\a.txt' dsd='*' dsd;    -----------→ dsd : 구분자가 연속되는 경우에는 결측을 넣어준다.
input employee$ bdate : mmddyy10. years;
run;

proc print data=employees;
run;

 

 

- dlm = '*'  : 구분자를 선언해준다.

- DSD

  • dlm = ',' : 구분자가 comma 가 된다.
  • ,, : 구분자가 연속되는 경우에는 결측을 넣어준다.
  • quotation 안에 있는 구분자는 구분자로 인식하지 않는다.  (예: 영어이름 'gildong, hond')

 

 

 

 

 

 

117. Debugger 를 활성화시켜주는 옵션 - /debug

 

Q. Which of the following programs correctly invokes the DATA step Debugger.  (C)

 

A.

data WORK.TEST debug;

 set WORK.PILOTS;

 State=scan(cityState,2,' ');

 if State="NE' then description='Central'

run;

 

 

B.

data WORK.TEST debugger;

 set WORK.PILOTS;

 State=scan(cityState,2,' ');

 if State="NE' then description='Central'

run;

 

 

C.

data WORK.TEST /debug;

 set WORK.PILOTS;

 State=scan(cityState,2,' ');

 if State="NE' then description='Central'

run;

  • /debug : 문법에 오류가 있는지 없는지 찾아주는 옵션

 

D.

data WORK.TEST /debugger;

 set WORK.PILOTS;

 State=scan(cityState,2,' ');

 if State="NE' then description='Central'

run;

 

 

 

 

 

 

119. Not in( ) 문법

Consider the data step:

 

infile 'C:\class1.csv' dsd;

input Name $ Sex $ Age Height Weight;

if Age NE 16 and Age NE 15 then Group=1;

else Group=2;

 

 

Q. Which of the follwing assignment for variable group are functionally equivalent to the original statement used in the above data step?

   (if Age not in(15,16) then Group=1; else Group=2;)

 

  • if Age not in(15,16) then Group=1; else Group=2;   (O)
  • Where Age not between 15 and 16 the Group=1; else Group=2;   (X)
  • Data step 에서는 Where 절을 사용할 수 없다. (SQL 구문에서는 가능하다.)

 

 

 

 

 

122. First / Last 속성

 

The following SAS program is submitted:

 

data WORK.TOTAL;

set WORK.SALARY;

by Department Gender;

if FIrst.Gender the Payroll=0;

Payroll + Wagerate;

if Last.Gender;  -----------→ Last.Gender 가 1 일 때 실행된다.

run;

 

The SAS data set WORK.SALARY is currently ordered by Gender within Department.

 

Q. Which inserted coed will accumulate subtotals for each Gender within Department?  (Gender)

 

Department Gender Salary Wagerate First.Gender Last.Gender Payroll
생산 10 0.5 1 1 0.5
생산 20 0.2 1 0 0.2
생산 30 0.2 0 1 0.4
제조 10 0.7 1 0 0.7
제조 10 0.7 0 1 1.4
제조 20 0.4 1 0 0.4
제조 20 0.4 0 1 0.8
  • Last.Gender = 1 일때의 Payroll 데이터를 갖는다.

 

Department Gender Payroll
생산 0.5
생산 0.4
제조 1.4
제조 0.8

 

 

 

 

 

 

 

124. input, put, char, tranwrd 함수

 

Given the SAS data set WORK.ORDERS :

 

WORK.ORDERS

order_id    customer    shipped 

9341 Josh Martin 02FEB2009    -----------→ shipped 는 수치형 데이터인데 format 이 적용되어 있다.

9874 Rachel Lords 14MAR2009

10233 Takashi Sato 07JUL2009

 

The variable order_id is numeric , customer is character, shipped is numeric, contain a SAS date value, and is shown with the DATE9. format-----------→ 숫자인데 format 이 씌워져 있기 때문에 '02FEB2009' 으로 보인다. 

 

 

A programmer would like to create a new variable, ship_note, that shown a character value with the order_id, shipped date, and character name.

 

For example, given the first observation ship_note would have the value

"Order 9341 shipped on 02FEB2009 to Josh Martin".

 

 

 

Q. Which of the following statement will correctly create the value and assign it to ship_note?

   (ship_note = catx(' ',Order_id,'shipped on',put(shippped,date9.),'to',customer)

 

 

A. ship_note = catx(' ',Order_id,'shipped on',input(shippped,date9.),'to',customer)

  • input( , informat) : 문자형 → 숫자형 

 

B. ship_note = catx(' ',Order_id,'shipped on',char(shippped,date9.),'to',customer)

  • char(customer,1)  = J, R, H
  • char(customer,2) = o, a, a
  • 해당 번째의 값을 보여준다.

 

C. ship_note = catx(' ',Order_id,'shipped on',transwrd(shippped,date9.),'to',customer)

  • tranwrd : 단어를 바꿔주는 역할   (transwrd 아님)
  • tranwrd (대상변수, 바꿀 단어, 바뀔 단어)
  • 예) tranwrd(cutomer, "o", "99") = J99sh Matin  Rachel L99rds  Takashi sat99 

 

 

D. ship_note = catx(' ',Order_id,'shipped on',put(shippped,date9.),'to',customer)  

  • catx(' ', ~ ) : 공백으로 연결
  • put( , format)  : 숫자형 → 문자형
  • shipped 수치형인데 format 을 씌워 문자형처럼 보인다 !! 이런경우 PUT 함수를 써준다 !!!

 

 

 

 

 

127. Mean(of Rev:)

 

Given the SAS data set WORK.ONE:

 

Obs Revenue2008  Revenue2009  Revenue2010 

1  1.2  1.6  2.0

 

The following SAS program is submitted:

 

data WORK.TWO;

set WORK.ONE;

TOTAL = mean(of Rev:);    -----------→ Rev 로 시작하는 모든 변수들의 평균

run;

 

Q. What value will SAS assign to Total?   (1.6)

 

 


Q. 만약 세 변수중 하나가 결측값을 가지고 있다면?

 

Obs Revenue2008  Revenue2009  Revenue2010

1  .  1.6  2.0

 

mean(of Rev:)   =  1.8     -----------→ 결측은 고려하지않고 평균을 계산한다.

 

 

함수와 연산의 차이 

total2 = mean(of Rev:)

total3 = (Revenue2008 + Revenue2009 + Revenue2010) / 3

 

total2 = 1.8   

total3 = .

 

  • 함수는 인수에 결측이 있어도 결과는 특정값으로 나온다.
  • 연산의 경우 결측이 있다면 결과값도 무조건 결측으로 나온다 !! 

 

128. ERROR 읽는 법

 

A SAS program is submitted and the following SAS log is produced:

 

data gt100;

set ia.airplanes  -----------→  세미콜론 빠짐 !

if mpg gt 100 then output;

 

ERROR : File WORK.IF.DATA dose not exist.     -----------→ WORK 라이브러리에 IF 라는 데이터셋 없다는 뜻

ERROR : File WORK.MPG.DATA dose not exist.

ERROR : File WORK.GT.DATA dose not exist.

ERROR : File WORK.THEN.DATA dose not exist.   -----------→ 이 값들을 데이터셋으로 인식하고 있다. 

ERROR : File WORK.OUTPUT.DATA dose not exist.                    ==> SET 구문 오류

 

run;

 

 

The IA libref was previously assigned in this SAS session.

 

Q. Which one of the following corrects the errors in the LOG?

  • Add a semicolon at the end of the SET statement.

 

 

 

 

 

 

 

130.  OR 에 변수 입력을 안한 경우

 

A SAS PRINT procedure output of the WORK.LEVELS data set is listed below:

 

Obs name level

1 Frank 1

2 Joan 2

3 sui 2

4 Jose 3

5 Burt 4

6 Juan 1

 

The following SAS program is submitted:

 

data work.expertise;

set work.levels;

if level =. then expertise = "Unknown";

else if level=1 then expertise = "Low";

else if level = 2 or 3 then expertise = "Medium";    -----------→  SAS 에서 [level=2] OR [3] 으로 인식한다 !! (항상 참이다)

else expertise = "High";

run;

 

 

Q. Which of the follwoing values does the variable EXPERTISE contain?

   (Low, Medium, Unknown only)

 

if level =. then expertise = "Unknown";

else if level=1 then expertise = "Low";

else if level = 2 or 3 then expertise = "Medium";  

 

 

  • 결측이 아니거나 1 이 아니면 모두 "Medium" 이 값으로 들어간다.
  • level 이 2 또는 3일 때 "Medium" 값을 가지고 싶다면
  • else if level=2 or level=3 then expertise = "Medium";   또는
  • else if level in {2,3}  then expertise = "Medium";  

 

 

 

 

 

133. Pageno

 

The following SAS program is submitted:

 

options page no = 1;  -----------→ 페이지 번호 1부터 시작

 

proc print data=sasuser.houses;

run;

 

proc means data=sasuser.shoes;

run;

 

The report created by the PROC PRINT procedure step generates 5 pages of output.

 

Q. What is the page number on the first page of the report generated by the MEANS procedure step?  (6)

  • MEANS 결과는 6 페이지 부터 생긴다.

 

 

 

 

134. DATE - Report 에 Time 표시

 

Q. Which one of rhe following SAS system options displays the time on a report?   (DATE)

 

  1. TIME   (X)
  2. DATE  (O)   -----------→ 날짜와 시간 모두 나타낸다.
  3. TODAY   (X)
  4. DATETIME   (X)

 

- Global 옵션 -

option DATE;  

proc print data= test;

run;

 

- Global 옵션 취소하는 방법 - 

option NODATE;    -----------→  NO (부정) 을 붙인다.

proc print data= test;

run;

 

  • HTML 상에서는 안보인다.
  • 도구 → 옵션 → 우선설정 → 결과 → 리스트 생성 체크 한 후, 리스트를 보면 날짜가 나와있다.

 

 

 

 

 

135. NONUMBER - Report 에서 페이지 번호 출력 안하기

 

Q. Which one of the following SAS system options prevents the page number from appearing on a report?   (NoNumber)

 

  1. NONUM   (없는 옵션으로 오답)
  2. NOPAGE   (없는 옵션으로 오답)
  3. NONUMBER    -----------→  노벰버로 암기
  4. NOPAGENUM   (없는 옵션으로 오답)
  • 페이지 번호를 출력하려면 부정(NO) 을 빼고, NUMBER 지정하면 된다.

 

 

 

 

 

 

138. MEANS procedure 계산에 사용되는 변수 - 결측값 없는 numeric 변수

 

Q. Unless sepecified, which variables and data values are used to calculate statistics in the MEANS procedure?

  1. non-missing numeric variable values only.   (O)
  2. missing numeric variable values and non-missing numeric variable values only.
  3. non-missing character variables and non-missing numeric variable values only.   (문자형 변수 사용 X)
  4. missing character variables, non-missing character variables, missing numeric variable values, and non-missing numeric variable values.     (문자형 변수 사용 X)

 

  • 결측이 섞여있는 수치형 데이터셋을 사용하면?  → 결측을 빼고 수치형 변수만 이용한다 !! 

 

 

 

 

 

 

139. Report 를 보고 역으로 코드 구현하기

 

The following SAS program is submitted:

 

proc sort data = sasuser.houses out=houses;

by style;

run;

 

proc print data=houses;

< CODE >

run;

 

 

Click on the Exhibit button to view the report produced.

 

Q. Which of the following SAS statement(s) create(s) the report?

 

 

  • 원래 proc print datahouses; run; 을 하면 obs 열 (observation) 이 생긴다.
  • 위 문제의 결과물을 보면 obs 열이 없고, Style 이 기준이다.   
  • 따라서 기준을 바꿔야 한다. --→ ID Option 을 사용

 

 

 

  • VAR statement 에 style 은 들어가지 않음을 주의!!!

 

 

Q. 만약 VAR statement 에 style 을 할당하면?

 

 

 

 

  • Style 값이 중복된다 !! 

 

[정답 코드]

proc print data = houses;

id style;

var bedrooms baths price;

run;

 

'자격증 > SAS BASE' 카테고리의 다른 글

SAS Certification Base Programming 연습문제  (0) 2023.01.18
SAS Crambible 정리  (2) 2023.01.16
Chapter 5. Reading SAS Data Sets  (0) 2023.01.06
Chapter 4. Formatting Data Values  (0) 2023.01.04
Chapter 3. Producing Detail Reports  (0) 2023.01.03