SAS P1 L7 Flashcards

1
Q

How assign a libref to an Excel workbook?

How will worksheets be handled?

A
  • Use SAS/Access LIBNAME statement to assign libref to Excel workbook.
  • SAS will treat each worksheet in workbook as though it were an SAS data set.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does SAS/Access do?

What does it use?

A
  • SAS/Access provides data connectivity and integration between SAS and third party data sources.
    - Examples: Microsoft Excel, Oracle, other db
  • Uses special interfaces (bought separately) to read data from and write data to other databases, same as reading, writing to SAS library
  • called SAS/Access Data Access Engines
  • must be included in SAS installation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How find out what is included in SAS license on site?

Syntax:

A

Use PROC SETINIT to find out what is included in local license.

PROC SETINIT;
RUN;

Will generate list of all licensed SAS products and other info such as site number for tech support.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Syntax for using SAS/Access LIBNAME statement to access database?

How cite workbook?

A

LIBNAME libref {engine} “workbook-name” {options};

workbook-name needs to include path, file name, extension.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is bitness?

Why does it matter?

A

Bitness is how many bits data uses to encode - SAS, Excel can use either 32 or 64 bits. Need to use correct Access engine to account for data matching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Working between SAS and Excel files:
If bitness is the same, which Access engine can be used?
If bitness is different, which engine must be used?
What if remote server?

A

Bitness is same: use default (Excel Access) engine.
Bitness is different: use pcfiles server engine.

Can’t use pcfiles with remote server. ? what to use.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Syntax of LIBNAME statement with default engine?

Syntax of LIBNAME statement with pcfiles engine?

A

LIBNAME libref {engine} “workbook-name” {options};
LIBNAME libref pcfiles {PATH=}”workbook-name” {optionss};
- must have PATH= for pcfile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is appearance of library icons if using data outside SAS?

A

library icons look different – have little globe in front – indicate data is outside SAS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How are excel files organized after opened with engine?

What if it is a spreadsheet ?

A
  • worksheet = data set within “library”

- if worksheet name ends with $, = spreadsheet

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Using excel spreadsheet: name ends in $
Problem: valid SAS data set name CANNOT contain $
How handle this?

A

Will need to refer to worksheet in special way.

Get around by using SAS name literal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an SAS name literal?
How do you write it?
What does it allow you to do?
Example?

A
  • SAS name literal: name token that is expressed as a string within quotation marks, followed by upper or lower case N.
  • This enables special characters or blanks in data set names.
  • Ex: libref.’worksheetname$’n
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens when SAS has libref assigned to Excel workbook?

if want to use workbook in Excel

A

Workbook CANNOT be opened in Excel when SAS has libref assigned to it.
Must dissociate file first.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you dissociate a libref from an Excel file?

Example: with orionx

A
Dissociate at end via:
      LIBNAM libref CLEAR;
Ex: LIBNAM orionx CLEAR;
     (orionx = libref name)
Disconnects from data source, closes resources associated with connection.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How access Oracle database?

Which engine to use?

A

To access Oracle db, use LIBNAME statement:
LIBNAME libref engine {SAS/Access options};

SAS/Access engine = ORACLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are other connection options required to access Oracle db?

A
user=      optional oracle user name
password= (or pw=)   must be used if have "user="
path=       Oracle driver, node and database. SAS/Access uses same Oracle path designation that you use to connect to Oracle directly.
schema=  schema allows you to read database objects, such as tables and views. If eliminated will get default schema.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How does SAS handle Oracle db when you use LIBNAME statement?
How reference table in database?

A

SAS treats Oracle db just like SAS library.

Reference any table in database by using 2 level SAS name.

17
Q

SAS oracle example:

A

libname oralib oracle user=edu101 pw=edu101 path=dbmssrv schema=educ;

proc print data=oralib.supervisors;
where state in (‘NY’ ‘NJ’)’
run;

18
Q

How dissociate Oracle database at end of program?

A

To dissociate Oracle db at end of program:

LIBNAME oralib CLEAR;