Licence
Confirm expiry date using proc setinit; run;
Details are written to the log
To update your SAS licence run the license tool from the SAS windows start menu
ASSIGN LIBRARY
Libname <libref> <path>;
Libref max 8 characters, either letters, underscore, or numbers but cannot start with number; no characters.
It is good to start a programme with path macro: %let path=<folder path>;
To invoke the macro: libname <libref> "&path";
MACRO VARIABLES REQUIRE DOUBLE QUOTES
To change a libref: libname <libref> clear;
DATA STEP
Data <new name>;
Retain <variables>; can be used to set order of variables (must come before set statement)
Set <libref.file>;
Length <variable><$> W or <variable> w.d; where W=number of print places for character variable or for numerical W=bites and .d = decimal places
Assign new variables ; type new variable name and then define
Label;
Format
Length;
Where; create a data subset by limiting to a particular level of a variable
Drop <variables>; if drop statement is used within set statement then variables are not read into the PDV (drop= ) and are not available for processing, otherwise they can be read in any statement from pdv
Keep <variables>; limits the variables that are saved to the new dataset
If condition;
Multiple data sets an be created in one data step, which is best done with a select function:
Select (<variable>);
When ('level1') output data1;
When ('level2') output data2;
Otherwise; optional to otherwise output other
End;
To avoid errors due to capitalisation, the upcase function can be inserted eg select (upcase(<variable>))
Do-end can be added to a select group to execute multiple statements
When ('level1') do;
Newvariable=1; to new data set 'newvariable' is created with value 1
Output data1;
End;
To collapse levels of a variable, e.g, if few observations in one cateory:
Define new variable to = old variable; follow with if statement
<new_variable> = <old_variable>;
if old_variable=3 then new_variable=2; this collapses 3 into 2.
Convert character to numerical variable:
numvar = INPUT(charvar, best32.);
comp_score = comp_score + 0
PROC SORT
Used to create sorted report or merge two data sets.
...