Reading Other Data File Types Flashcards
How do you access an excel file in SAS?
Use SAS/ACCESS LIBNAME statement. Then SAS treats each worksheet in the workbook as a SAS data set.
SAS/ACCESS LIBNAME statment
LIBNAME libref (engine) (PATH=) “workbook file path” (options);
Example:
LIBNAME orionx pcfiles path=”&path/sales.xls”;
(PATH= is used with pcfiles engine)
How do you determine which engine to use in SAS/ACCESS LIBNAME statement?
SAS and MS Office offer 32-bit and 64-bit.
If bitness is the same, use excel engine.
If bitness is not the same, use pcfiles engine.
What is the SAS name literal?
libref.’worksheetname$‘n
It’s a way to allow special characters or blanks in data set names. Useful since excel files are displayed in SAS with special character $.
Why is it important to dissociate a libref given to an excel file?
SAS locks the excel document while libref is assigned to it, and you won’t be able to open in in excel.
How do you access data from a database?
Use SAS/ACCESS LIBNAME statement:
LIBNAME libref engine (SAS/ACCESS options);
engine is the database (e.g. oracle)
SAS/ACCESS options:
USER=
PASSWORD=
PATH=
SCHEMA=
What are 3 types of raw data files?
text file, CSV file, and ASCII file
What are 2 ways data can be presented in a raw data file?
Delimited file: Data values arranged sequentially. Data values separated by spaces or other special characters
Fixed column file: arranged in columns. Each field has a set width in every record.
What important information about each record do you need to specify to read a delimited raw data file in SAS?
Location of data value in the record, name of SAS variable in which to store the data, and the type of SAS variable
What are the 3 different techniques to read raw data files in SAS?
- List input: reads standard and nonstandard data separated by delimiter
- Column input: reads standard data arranged in columns
- Formatted input: reads standard and nonstandard data arranged in colums
What is the difference between standard and nonstandard data?
SAS can read standard data without any special intructions.
Nonstandard data can include dates or values with special characters. SAS needs extra intructions to read this data.
How do you use the DATA Step to read raw data?
DATA new-data-set;
INFILE “file path” dlm=’,’;
INPUT variable1 variable2 $ variable3 $;
RUN;
dlm = what separates the data values. The default is a space or blank
INPUT specifies variables in order in which they appear in the raw data file. Character variables are followed by $
During compilation phase, what does SAS create that is particular to raw data files?
SAS creates an input buffer before the PDV. SAS reads data from the raw data file into the input buffer and the PDV reads from the input buffer.
It looks like a ruled grid where each character in the data value is placed in a different square
How do you specify the length of certain variables?
Use the LENGTH statement
LENGTH variable(s) ($) length;
Note: This needs to go before the input statement.
Note: The variables will be listed in the order and case used in the length statement.
What is the difference between formats and informats?
Formats tell SAS how to write a value.
Informats tell SAS how to read a valued.