Q. associate the fileref Crime with raw data file
- filename crime 'c:\states\data\crime.dat';
- assign fileref by using a FILENAME statement
- fileref 를 assign 할 때는 FILENAME 을 사용 !!
- LIBNAME 문을 사용하여 assign a libref 를 했던 것과 동일한 방식으로 진행
Q. delimited file
- which type of delimited file dose PROC IMPORT read by default?
- By default, the IMPORT procedure reads delimited files as varying record-length files.
- 만약 외부파일 (external file)이 fixed-length format 이면 PROC IMPORT 문 전에 (RECFM=F, LRECL=options 를 포함하는) OPTIONS 문을 사용한다.
Q. 일부 관측치만 IMPORT 하기
- Which programs correctly imports only the first seven lines from the external file that is delimited by a period(.)?
- (Hink: the first line in the external file contains variable names that you want to read.)
- delimited byt a period(.) 인 external file 로부터 첫 7번째 관측치만 import 하기
- (= Period 로 구분된 외부파일로부터 첫 7번째 관측치만 import 하기)
- Hint : external file의 첫 번째 line은 변수명을 포함한다. (변수명을 포함하여 import 하기)
options obs =7;
proc import datafile ="c:\ users\ test.txt"
out = exam
dbms=dlm
replace;
delimeter="."
getnames=yes;
run;
proc print data=exam;
run;
- 일부 관측치만 import 하려면 IMPORT precedure 전에 OPTIONS statements 에 OBS=option 지정
- 전체 파일을 import 하고 일부 관측치만 print 하려면 PROC PRINT 문 안에 OBS=option 사용
Q. Excel workbook file 을 읽고 SAS data set 으로 쓰기 위한 DATA step 에 SAS 가 필요한 정보
- a libref to referance the Excel workbook to be read
- the name and location (using another libref) of the new SAS data set
- the name of the Excel worksheet that is to be read
Q. PROC IMPORT 가 input file의 첫번째 행의 값인 SAS variable names를 생성하게 하고 싶다면?
- getnames=yes;
- getnames=No 를 지정하면 IMPORT precedure가 SAS 변수 이름을 VAR1, VAR2 ,... 로 생성시킨다.
- when you assign a fileref with an individual extenal file you specify the fileref in subsequent SAS statements and comments
filename workbook 'C:\certdata\workbook.txt';
proc import datafile=workbook;
dbms=dlm
out=workbook
replace;
getnames=yes;
run;
Q. PROC IMPORT precedure 로 import 할 수 있는 delimited file ?
IMPORT precedure
- read data from an external data
- write it to a SAS data set
- delimited file : a dilimiter (blank, comma, tabs) seperates columns of data vaules
- you can alse have a delimeter other than blanks, commas, tabs.
- In those cases, PROC IMPORT reads the data from the external data source as well.
- you can have a delimiter such as an ampersand ( & )
- blank, commas, tabs, & 으로 분리된 delimited file 을 import 할 수 있다.
Q. To override the DATA step default behavior that writes observations to output. what should you use in a DATA step (an OUTPUT statement)
- OUTPUT 구문은 SAS 데이터세트에 현재 처리 중인 관측치를 작성한다. OUTPUT 구문은 DATA step의 종료 시점에 작성되지 않고, OUTPUT 구문이 실행되는 즉시 데이터 세트에 현재 관측치를 작성한다. 만약 OUTPUT 구문에 출력되는 데이터 세트 이름을 지정하지 않으면, 관측치는 DATA 구분에 나열된 모든 데이터 세트에 작성된다.
- SAS 데이터세트에 현재 관측치를 작성한다.
- placing explicit OUTPUT statement in a DATA step, overrides the automatic output output, so that observations are added to a data set only when the explicit OUTPUT statement is executed.
- The OUTPUT statement overrides the default behavior of the DATA step.
- 참고 : https://statwith.tistory.com/3245
[SAS Statement] OUTPUT 구문
[SAS Statement] SAS 데이터 스텝 구문 사전 목록 o OUTPUT 구문 1. 목 적 OUTPUT 구문은 SAS 데이터 세트에 현재 처리 중인 관측치를 작성한다. OUTPUT 구문은 데이터 스텝의 종료 시점에 작성되지 않고, OUTPUT
statwith.tistory.com
'자격증 > SAS BASE' 카테고리의 다른 글
| Chapter 7. Understanding DATA Step Processing (1) | 2022.12.12 |
|---|---|
| Chapter 6. Creating Report (0) | 2022.12.10 |
| chapter 5. Identifying and Correcting SAS Landuage Errors (0) | 2022.12.10 |
| Chapter 3. Accessing Your Data (0) | 2022.12.06 |
| Chapter2. Basic Concepts (0) | 2022.12.06 |