Podcast
Questions and Answers
What happens when the FORCE option is used with Proc Append?
What happens when the FORCE option is used with Proc Append?
If a data value in a variable in the data= data set is longer than the corresponding variable in the base= data set, it will be truncated. Variables not in the base= data set will be dropped, and mismatched types will result in missing values.
What is match merging?
What is match merging?
Match merging combines observations from two or more data sets into single observations based on a common variable.
What happens when two data sets have variables with the same name during a merge?
What happens when two data sets have variables with the same name during a merge?
The values from the last data set in the merge statement will overwrite the values from the preceding data sets.
What types of merges can occur in a data set?
What types of merges can occur in a data set?
Signup and view all the answers
What does the IN= data set option do?
What does the IN= data set option do?
Signup and view all the answers
How is the MEAN function in SAS used?
How is the MEAN function in SAS used?
Signup and view all the answers
What does the INPUT function do?
What does the INPUT function do?
Signup and view all the answers
What does the PUT function do?
What does the PUT function do?
Signup and view all the answers
The concatenation operator in SAS is represented by ___.
The concatenation operator in SAS is represented by ___.
Signup and view all the answers
What is the purpose of the MDY function in SAS?
What is the purpose of the MDY function in SAS?
Signup and view all the answers
What do the DAY, YEAR, and MONTH functions return?
What do the DAY, YEAR, and MONTH functions return?
Signup and view all the answers
Which functions count the number of times intervals are crossed?
Which functions count the number of times intervals are crossed?
Signup and view all the answers
What is the role of nested DO loops in SAS?
What is the role of nested DO loops in SAS?
Signup and view all the answers
Which variables are analyzed by default in PROC MEANS?
Which variables are analyzed by default in PROC MEANS?
Signup and view all the answers
What default statistics are produced by PROC MEANS?
What default statistics are produced by PROC MEANS?
Signup and view all the answers
How can you choose specific statistics in PROC MEANS?
How can you choose specific statistics in PROC MEANS?
Signup and view all the answers
How can you choose the number of decimal places in PROC MEANS?
How can you choose the number of decimal places in PROC MEANS?
Signup and view all the answers
How do you choose variables to be analyzed in PROC MEANS?
How do you choose variables to be analyzed in PROC MEANS?
Signup and view all the answers
The CLASS statement requires data to be sorted before using it in PROC MEANS.
The CLASS statement requires data to be sorted before using it in PROC MEANS.
Signup and view all the answers
What is the purpose of the OUTPUT statement in PROC MEANS?
What is the purpose of the OUTPUT statement in PROC MEANS?
Signup and view all the answers
Which statement is used to limit variables for frequency reports with PROC FREQ?
Which statement is used to limit variables for frequency reports with PROC FREQ?
Signup and view all the answers
What is the effect of format in PROC FREQ?
What is the effect of format in PROC FREQ?
Signup and view all the answers
What is a two-way frequency report?
What is a two-way frequency report?
Signup and view all the answers
What are NOFREQ, NOPERCENT, NOROW, and NOCOL options used for in PROC FREQ?
What are NOFREQ, NOPERCENT, NOROW, and NOCOL options used for in PROC FREQ?
Signup and view all the answers
What does the ODS statement do in SAS?
What does the ODS statement do in SAS?
Signup and view all the answers
What is the syntax for creating a table of contents with the ODS statement?
What is the syntax for creating a table of contents with the ODS statement?
Signup and view all the answers
How do you initialize an accumulator variable in SAS?
How do you initialize an accumulator variable in SAS?
Signup and view all the answers
An accumulator variable's value resets to 0 after each DATA step execution.
An accumulator variable's value resets to 0 after each DATA step execution.
Signup and view all the answers
How are variable lengths assigned in SAS?
How are variable lengths assigned in SAS?
Signup and view all the answers
What is the DROP statement used for?
What is the DROP statement used for?
Signup and view all the answers
What is the purpose of the SELECT statement in SAS?
What is the purpose of the SELECT statement in SAS?
Signup and view all the answers
What does the POINT= option do in the SET statement?
What does the POINT= option do in the SET statement?
Signup and view all the answers
What is interleaving in SAS?
What is interleaving in SAS?
Signup and view all the answers
What does the RENAME= option do in SAS?
What does the RENAME= option do in SAS?
Signup and view all the answers
What is the PROC APPEND procedure used for?
What is the PROC APPEND procedure used for?
Signup and view all the answers
Study Notes
PROC MEANS
- Analyzes every numeric variable in a SAS data set, excluding missing values during calculations.
- Produces default statistics: count, mean, standard deviation, minimum, and maximum.
- To specify summary statistics, add them to the PROC MEANS statement. Use
MAXDEC = k
to set decimal places. - Use the VAR statement to select specific variables for analysis, placed below the PROC MEANS statement.
- The CLASS statement groups observations for analysis without needing prior sorting; it should be positioned below the PROC MEANS statement.
- Creating an output dataset requires an OUTPUT statement with specified syntax for means and medians.
PROC FREQ
- Analyzes numeric and character variables, creating one-way frequency tables for each, displaying distinct data values.
- The TABLES statement limits variables for frequency reports and should be placed below the PROC FREQ statement.
- The PROC FORMAT enhances categories of values within the TABLES statement.
- Two-way (crosstabular) frequency reports analyze combinations of distinct values from two variables.
- Additional TABLES statement syntax includes various configurations for multiple variables.
ODS STATEMENT
- ODS supports output to formats like HTML, XML, RTF, PDF, and more; open with
ODS open-destination
and close withODS close-destination
. - Use BODY= or FILE= options to specify HTML file paths.
- Enabling CONTENTS= and FRAME= options creates a table of contents in an HTML output file, with both BODY= and FRAME= required for proper organization.
SUM STATEMENT
- The SUM statement initializes an accumulator variable to 0, adding expressions' results.
- A RETAIN statement can set initial values other than 0 to accumulator variables and retains them through the data step.
IF-THEN ELSE STATEMENTS
- Numeric constants in IF statements are evaluated as true if non-zero or non-missing and false if 0 or missing.
- DO groups allow for multiple statements under IF conditions.
VARIABLE LENGTHS
- Numeric variables default to 8 bytes; character variables take the length of their first instance.
- The LENGTH statement can predefine the length of character variables before their first encounter.
DATA STEP OPTIONS
- WHERE condition applies to existing input data variables and operates before merging; IF applies afterward.
- DROP= and KEEP= options specify variable inclusion or exclusion in data sets during processing.
- The DROP statement excludes variables from the output data set while KEEP includes only specified variables.
SELECT STATEMENT
- SELECT statements serve as an alternative to IF-THEN-ELSE for managing variable assignments.
- SELECT can operate with or without an explicit select expression, evaluating conditions sequentially.
BY STATEMENT
- Requires sorted data sets and creates FIRST. and LAST. temporary variables during data step processing.
- Accumulates totals using BY statements to view subtotals by specific groupings.
OUTPUT STATEMENT
- SAS typically performs implicit output upon reaching the RUN statement; explicit outputs are done using the OUTPUT statement.
POINT= and END= OPTIONS
- POINT= enables reading specific data set observations directly; requires a STOP statement to avoid infinite loops.
- END= indicates the last observation in a data set for additional processing or reporting purposes.
MATCH MERGING
- Combines data sets based on a common BY variable, requiring both datasets to be pre-sorted.
- The RENAME= option resolves naming conflicts, ensuring distinct variable recognition in the merged dataset.
APPENDING DATA SETS
- PROC APPEND allows for adding dataset observations to an existing base dataset; it requires matching variable structures.
- The FORCE option may be used when there are discrepancies in variable types or lengths.### Variable Handling in Data Sets
- Variable length is determined by the first data set containing the variable name when multiple data sets are involved.
Merges: One-One, One-to-Many, Many-to-Many
- One-to-one merges have unique matching by variable values across data sets.
- One-to-many matches occur when a unique by variable value corresponds to multiple values in another data set.
- Many-to-many matches feature multiple by variable values correlating with multiple values in another data set.
Selecting Observations with IN= Option
- IN= data set option creates a variable indicating the contribution of a data set to the current observation.
- A temporary numeric variable is generated, where 0 implies no contribution and 1 indicates contribution.
Mean and Sum Functions
- Mean can be calculated using
MEAN(OF variable list)
syntax, whereVar1 - Var4
computes the mean of specified variables. - SUM function follows similar syntax for summing variables, while ignoring missing values.
- Be cautious that
SUM(Var1 - Var4)
computes Var1 minus Var4 rather than a sum.
CONVERTING CHARACTER TO NUMERIC
- INPUT function converts character variables to numeric using a specified informat.
- A special informat is necessary for non-standard numeric formats (e.g., currency).
- Example:
Num_Pay = INPUT(payment, dollar9.2)
converts payment in character format to numeric.
Automatic Conversion of Character Variables
- SAS attempts automatic conversion of character variables to numeric for numeric operations.
- If character values are formatted incorrectly (e.g., "$23.45"), the operation results in a missing value.
- Manual conversion is recommended for accuracy.
Converting Numeric to Character
- PUT function is used for converting numeric variables to character format.
- Format specified must be numeric to ensure appropriate string conversion.
Concatenation Operator
- The
||
operator concatenates character strings. - Example:
Com_Address = address || ZIP
incorporates values with possible leading blanks.
Date and Time Functions
- MDY(Mon, Day, Year) returns a SAS date value.
- TODAY() and DATE() provide the current date as a SAS date.
- TIME() and DATETIME() yield current time and full date-time values respectively.
Day, Year, and Month Functions
- DAY(SASdate) extracts the day of the month.
- YEAR(SASdate) returns the four-digit year.
- MONTH(SASdate) provides the month as an integer.
INTCK and INTNX Functions
- INTCK counts the number of interval crossings between two date/time values based on specified intervals.
- INTNX shifts a date by an increment, aligning it to the specified interval (beginning, middle, end).
String Manipulation Functions
- SCAN retrieves specific words from strings.
- SUBSTR extracts or replaces parts of a string.
- TRIM removes trailing blanks, while LEFT aligns strings.
- UPCASE and LOWCASE adjust character case, with PROPCASE converting to proper case.
- CATX concatenates while removing blanks and adding separators; INDEX and FIND search within strings.
DO Loops: Index and List
- DO loop syntax allows iteration through a range defined by start, stop, and increment.
- Index variable holds iteration values and cannot be modified within the loop.
- DO loops can also be list-based, executing once for each value in the provided list.
DO WHILE and DO UNTIL Loops
- DO WHILE loops execute as long as a condition remains true.
- DO UNTIL loops execute until a condition becomes true, guaranteeing at least one execution.
Nested DO Loops
- Nested DO loops involve placing one DO loop within another.
- Ensure distinct index variables for each loop and correspond each DO statement with an END statement.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge with these SAS Exam 2 flashcards covering key PROC statements. Learn about default variable analysis, produced statistics, and how to customize summary statistics in SAS. Perfect for quick revision before the exam!