SAS P1 L2b Flashcards

1
Q

What is an SAS comment?

A

SAS Comments:
text that is ignored during processing
but is written to log (when program runs)

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

Uses for SAS comments?

A
  • document purpose of program
  • explain segments
  • mark SAS code as non-executing => commenting out code

Can help test program in stages:
comment out error free code
test only desired sections

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

What are the two types of comments?

A

2 types of comments:
Block comment
Comment Statement

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

How write a Block Comment?
begin?
end?

A

Block Comment:
begins with “/” (forward slash-asterisk)
ends with “
/” (asterisk-forward slash)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
Block comment:
length?
contain internal semicolons?
nested?
in column 1 or 2? why?
A
Block statement:
any length
CAN contain semicolons
CANNOT be nested
NO block comments in column 1 or 2 - some editors read as code -> request to end job
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How write Comment Statement?
begin?
end?

A

Comment statement:
begins with “*” (asterisk)
followed by text of comment
ends with “;” (semicolon)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
Comment Statement:
length?
contain internal semicolons?
nested?
in column 1 or 2?
A
Comment Statement:
any length (?)
CANNOT contain internal semicolons
?nesting
CAN begin in columns 1 or 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Syntax errors are?

3 common ones?

A

Syntax errors are program statements that don’t conform to rules of SAS

Common:
misspelled key words
missing semicolon
invalid options

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

How does editor indicate potential error?

A

Editor uses red to indicate potential errors

If data step has error, other steps following will also highlight since only work when in data step

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

When are syntax errors found?

A

Syntax errors are found during compilation, before program is executed

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

What does editor do if finds error? (3)

A
Editor will write:
- error or warning
- location
- explanation
Editor can also try to fix things - will show up in log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What if error statement actually looks ok?

A

Error is underlined - if that statement looks ok, probably missing semicolon before

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

What happens if unbalanced quotation marks?

A

Unbalance quotation marks:
Quotation mark counter keeps track
If detects uneven amount, won’t execute properly

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

Can use single? Double? quotation marks?

A

Both single and double quotes can be used, but not as pair to each other

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

Unbalanced quotation mark statement: appearance?

A

SAS will misread that statement and any following statements => will be colored purple = quoted string

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

Unbalanced quotation mark statement: error warning?

A

NO ERROR WARNING

  • banner will say “Data step still running”
  • have to stop executing program by cancelling submitted statements
17
Q

Unbalanced quotation mark statement: where will see issue? What happens?

A

SAS Studio will write msg to log about error
“quoted string too long or ambiguous”

If see any log message about quoted string, look for unbalanced quotation mark

Will try to repair with wrapper code, code will stop running.