Week 1 Flashcards
What are some useful conventions for SAS code?
Case-insensitive
SAS keywords are usually in CAPS
All SAS statements end with a ;
What is the DATA step?
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
What are PROC steps?
Importing external data sheets
Summarizing data
Graph or chart data
Run statistics
Model data
Aggregate, sort, transpose or rearrange data
What are some data set and variable name rules
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
Embedded comments
Start with comment;
Or
/comment*/
What are some common syntax errors?
Missing a RUN;
Omitting a;
Misspelled words
Leaving quotation marks on balanced or open
Using invalid options, keyword, terms
Adding a dataset
DATA Name (of dataset);
INPUT V1 V2 V3 Vcharacter $;
DATALINES;
Enter your data in rows by variable
RUN;
Rules on numeric data
Numbers as a raw value
Can have numbers 0–9, - , +, ., e
Missing data represented by a .
Cannot have $or commas
Cannot have leading zeros
What are character data rules?
Anything goes
Missing data represented by a space
Can be framed in Sicle or double quotation marks
Positional input with explicit formatting- numeric data
DATA filename;
INPUT @1 var1 3.0
This mean var1 goes in position 1, is 3 positions wide and no decimal points
Informat is #.#
Positional input with explicit formatting - character data
INPUT @10 charvar3 $10
This means that variable three is in position 10 is and his charac
Informat or input format
$#.#
What are the pros and cons of list input?
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 
Pros and cons of Column or position input
Pros: Reid data regardless of missing data position
Cons : need to be in proper column location, and need to know
Pros and cons of explicit formatting
Pros: a lost for specific formats of variables
No surprises
Cons: requires knowledge of the data
SAS libraries
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