SAS P1 L4c Flashcards

1
Q

Name some special WHERE operators

(5 plus a repeat)

A

CONTAINS

BETWEEN … AND

WHERE SAME AND

IS NULL or IS MISSING

LIKE

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

CONTAINS operator

what is it?

symbol?

Mnemonic?

Definition?

What does it do?

Case sensitive?

A

CONTAINS operator:
special WHERE operator
symbol = “?”
Mnemonic: CONTAINS
definition: includes a substring
CONTAINS checks if value contains substring
- position in substring doesn’t matter
CASE SENSITIVE

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

Special WHERE operators:

how define an inclusive range?

A

BETWEEN … AND

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

Special WHERE operators:

how augment a WHERE expression?

A

WHERE SAME AND

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

Special WHERE operators:

how check for missing value? (2 ways)

characters?

numeric?

A

IS NULL

IS MISSING

both work for character and numeric

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

Special WHERE operators:

how check for matching a pattern?

A

LIKE

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

LIKE
What does it use?(2) how many char work for?
consecutive?
how many can use in same pattern?
how express statement to match?

A

Uses 2 special symbols

% - can replace any number of characters (can be zero too)

_ (underscore) - replaces one character

can have consecutive underscores

can use both in same pattern

Need to be in quotes (entire statement) to match

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

What is an ID Statement?

A

ID Statement:

Used in PROC PRINT to specify different info to print instead of obs column

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

What does PROC SORT do?

what does it sort on?
types?
in what order does it sort?

A

PROC SORT:

can SORT on one or multi variables

char or numeric
ascending or descending order

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

How does PROC SORT work?
First?
Then?

Where does it put everything?

A

PROC SORT

first rearranges obs in input data set

then SAS creates data set that contains rearranged obs either by replacing original data set (= default)

or by creating new data set:

  • this is optional, would need semicolon after
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What’s needed for PROC SORT?

Number of statements?

A

PROC SORT needs three statements:

PROC SORT DATA= statement
(needed to specify data set)

BY statement - one or more BY variables

RUN statement

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

FORMAT of BY statement?

default?

what if want descending? for more than one var?

A

BY BY-variable(s)

(default is ascending)

need to specify descending in front of each variable wanted in descending order

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

Where else can use BY statement?

A

Can use BY statement in PROC PRINT too

  • to group data
  • data needs to already be sorted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Assigning Titles and Footnotes:

Where do titles appear?

Footnotes?

What are default title, footnote?

A

Titles are at top of page

Footnotes at bottom

Default title = “SAS System”

No default footnote

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

Syntax of TITLE?

Syntax of FOOTNOTE?

How change line printed on? default?

does quote type matter?

What kind of statements are they?

A

TITLEn ‘text’;

FOOTNOTEn “text”;

n indicates on which line title / footnote appears

If no number, assumes line 1

quotes around text can be single or double

TITLE and FOOTNOTE are GLOBAL statements

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

How change TITLE or FOOTNOTE?

What happens to other titles?

A

To change title or footnote, write a new title statement with the same number but new text

Also cancels all titles with line numbers less than changed title statement.

17
Q

How cancel all Titles / Footnotes?

Best practice?

A

Specify null title and footnote:

TITLE;
FOOTNOTE;
no #s, no text

Best practice is to do this at end of program.

18
Q

How assign temporary labels?

Syntax?

Length?

if multiple labels?

A

LABEL statement assigns temporary labels

Syntax:
LABEL variable1 = ‘label’
variable2 = ‘label’….;

labels can be up to 256 char

can specify multiple labels in one statement or use separate for each

19
Q

How tell PROC PRINT to display labels?

example syntax?

A

Must ADD LABEL to PROC PRINT to tell it to display labels:

PROC PRINT DATA= orion.sales label;

20
Q

What does SPLIT do?

What can you leave out if you use SPLIT?

A

SPLIT specifies control character to trigger line break.

  • A space can be the control character.
  • If use SPLIT, don’t need to specify label in PROC PRINT, SPLIT serves to do that.

PROC PRINT DATA= orion.sales split=”*”; (asterisk is control char)
VAR Employee_ID Last_Name Salary;
LABEL Employee_ID=”Sales ID”
Last_Name= “Last Name”
Salary= “Annual*Salary”
RUN;