Week 1 Flashcards

1
Q

What are some useful conventions for SAS code?

A

Case-insensitive
SAS keywords are usually in CAPS
All SAS statements end with a ;

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

What is the DATA step?

A

A series of statements where a new sas data set can be created, manipulated or altered, new variables can be created or existing variables changed, labeled, mathematical functions can be used like to combine variables

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

What are PROC steps?

A

Importing external data sheets
Summarizing data
Graph or chart data
Run statistics
Model data
Aggregate, sort, transpose or rearrange data

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

What are some data set and variable name rules

A

One to 32 characters in length
Can’t start with a number
All data sets have two part names signify where it’s stored in the data sent name
I.e. WORK.databasename if temp
LIBNAME.database

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

Embedded comments

A

Start with comment;
Or
/
comment*/

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

What are some common syntax errors?

A

Missing a RUN;
Omitting a;
Misspelled words
Leaving quotation marks on balanced or open
Using invalid options, keyword, terms

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

Adding a dataset

A

DATA Name (of dataset);
INPUT V1 V2 V3 Vcharacter $;
DATALINES;
Enter your data in rows by variable
RUN;

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

Rules on numeric data

A

Numbers as a raw value
Can have numbers 0–9, - , +, ., e
Missing data represented by a .
Cannot have $or commas
Cannot have leading zeros

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

What are character data rules?

A

Anything goes
Missing data represented by a space
Can be framed in Sicle or double quotation marks

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

Positional input with explicit formatting- numeric data

A

DATA filename;
INPUT @1 var1 3.0
This mean var1 goes in position 1, is 3 positions wide and no decimal points
Informat is #.#

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

Positional input with explicit formatting - character data

A

INPUT @10 charvar3 $10
This means that variable three is in position 10 is and his charac
Informat or input format
$#.#

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

What are the pros and cons of list input?

A

Pros: you do not need to know the column locations
Cons: not compact, must have spaces and can’t combine columns
Doesn’t handle missing data well sometimes doesn’t work with text files 

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

Pros and cons of Column or position input

A

Pros: Reid data regardless of missing data position
Cons : need to be in proper column location, and need to know

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

Pros and cons of explicit formatting

A

Pros: a lost for specific formats of variables
No surprises
Cons: requires knowledge of the data

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

SAS libraries

A

SAS temporarily saves data sets to the Work library, it the default. File are name WORK.filename

You can store data set permanently by using the LIBNAME statement to specify path
Files named LIBNAME:filename

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

Global options

A

Not tied to any data set
Remaining effect until they are changed
TITLE ‘xxxxx’;
OPTIONS ls =xx ps=x
-LS sets each line to be a maximum of X characters
-PS said the number of lines per output page at x lines maximum

17
Q

What command defines the names of variables?

A

INPUT
Basically names the columns
Character variables must be followed by a dollar sign

18
Q

How is missing data handled?

A

For numeric variables, missing values are denoted by .
Missing Character values denoted by a space

19
Q

What is column input?

A

All columns need to lineup and you specify the position
Add an index line
INPUT var1 1-3, var2 4-5, var3 7-10;

20
Q

Positional input with implicit formatting

A

Data must be in proper columns @# denotes the first position in a row for each data element

21
Q

Positional input with explicit formatting

A

• Data must be in the proper columns. @# denotes data position in row for
each variable.
• Denote informat
– Type format
• Numeric – format as #.#
• Character – format as $#. or $#.#
– Length is denoted by the first number in #.# or #. or $#.# or $
ie. INPUT @1 variable 3.0;
3 digits 0 decimals

22
Q

What is an informat?

A

Informats are used to specify the data type and field width of an input value
#.# for numeric variables
$#.# for character variables

23
Q

What does the double trailing @@ do?

A

Instructs sas to use multiple iterations of the data step to build multiple observations from each record of raw data.
XY@@ will repeat XY for multiple observations until it reaches the end of

24
Q

How do you create a permanent library?

A

LIBNAME dataset “c/:……”

25
Q

How do you save a temporary dataset in the WORK library into a permanent library?

A

DATA mydata.mydataset;
SET WORK.tempdataset;
RUN;
This is equivalent to this DATA step
DATA mydata.mydataset