SAS Base Programming flashcards
SAS Base Programming · Build recall with a focused review session.
32 cards. Read the term and the definition here. The deck at the top of this page is optional.
- LIBNAME statement
- Assigns a libref to a directory or SAS library so data sets can be referenced as libref.member. Syntax: LIBNAME libref 'path'; librefs are 1-8 characters.
- Program Data Vector
- The DATA step's memory area holding one observation's variables during execution. It is created at compile time and reset each iteration except for retained variables.
- INFILE DSD option
- Reads delimited files, treating consecutive delimiters as missing values and stripping quotation marks from character values. Used with DLM= to set the delimiter.
- MISSOVER option
- INFILE option that assigns missing values to any variables not filled by a short input record instead of holding the record for more data.
- PROC IMPORT DBMS=
- Reads external files such as XLSX, CSV, or delimited text into a SAS data set. DBMS= specifies the file type and OUT= names the output data set.
- ARRAY statement
- Defines a group of variables referenced by a common name and index, for example ARRAY a[3] x1-x3; DIM(a) returns the number of elements.
- Automatic variable _N_
- Counts DATA step iterations. It equals 1 during the first iteration and increases by one each subsequent iteration; useful for selecting rows.
- MERGE versus SET
- SET stacks observations from multiple data sets vertically. MERGE combines them horizontally by matching BY values and requires sorted input for one-to-one matching.
- PROC SORT NODUPKEY
- Sorts a data set and removes observations with duplicate values of the BY variables, keeping the first occurrence of each key.
- RETAIN statement
- Prevents a variable from being reset to missing at the start of each DATA step iteration and can assign an initial value.
- WHERE versus IF
- WHERE selects observations before they enter the PDV and cannot use newly computed variables. IF executes after the PDV is populated and can use computed values.
- LAG function
- Returns the value of its argument from a previous DATA step iteration; LAG(n) looks back n iterations using an internal queue.
- FIRST. and LAST. flags
- Automatic variables that are 1 for the first or last observation in a BY group. They require data sorted by the BY variables.
- PROC TRANSPOSE
- Converts observations to variables or variables to observations. VAR selects columns, ID names new columns, and BY preserves group structure.
- SUM statement
- Syntax var+expression; retains var across iterations, ignores missing values in the expression, and treats them as zero.
- INPUT and PUT functions
- INPUT converts a character value to numeric using an informat. PUT converts a numeric value to character using a format.
- _ERROR_ variable
- Automatic DATA step variable set to 1 when a data error occurs during execution and reset to 0 at the start of each iteration.
- ERRORABEND option
- System option that causes SAS to terminate immediately when an error occurs. The default NOERRORABEND allows processing to continue.
- OPTIONS ERRORS=
- Limits how many observations with data errors print error messages in the log. Default is 20; setting it to 0 suppresses messages.
- PUT _ALL_ statement
- Writes every variable currently in the PDV, with names and values, to the SAS log. Used to debug DATA step logic.
- ABORT statement
- Stops DATA step execution. ABORT CANCEL cancels submitted statements, while ABORT RETURN returns control to the calling environment.
- SYSERR macro variable
- Contains the return code from the most recent SAS procedure or DATA step; a nonzero value indicates an error condition.
- Compile versus execution errors
- Compile errors are syntax problems detected before the DATA step runs. Execution errors occur while processing data, such as invalid numeric conversion.
- Missing values note
- Log message 'Missing values were generated' appears when numeric operations create missing values, often from character-to-numeric conversion.
- PROC PRINT NOOBS
- Prints a data set without the observation number column. Other options include LABEL, BY, ID, VAR, and SUM.
- PROC FREQ MISSING
- Includes missing values as a category in frequency tables. Without MISSING, observations with missing values are excluded from the table.
- PROC MEANS CLASS
- Produces summary statistics for each level of the CLASS variables. NWAY outputs only the highest-level class combination.
- PROC REPORT DEFINE
- Specifies a column's usage, such as DISPLAY, GROUP, ORDER, or ANALYSIS, and its label, width, and format in a report.
- ODS HTML statement
- Routes procedure output to an HTML file. Open with ODS HTML FILE='name.html'; and close with ODS HTML CLOSE.
- TITLE statement
- Adds a title line above report output. TITLE; clears all titles; TITLE2 adds a second title line.
- PROC TABULATE
- Creates dimensional summary tables using TABLE statements with row and column expressions; CLASS variables define categories and VAR variables supply analysis values.
- DATA _NULL_ PUT
- A DATA step with no output data set, using PUT to write custom report lines to the log or to a file named in a FILE statement.