SAS Exam 2 Flashcards
35 Questions
100 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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?

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?

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?

<p>One-to-one merges</p> Signup and view all the answers

What does the IN= data set option do?

<p>It creates a variable that indicates if a data set contributes to the current observation.</p> Signup and view all the answers

How is the MEAN function in SAS used?

<p>It computes the mean of a list of variables, like MEAN(OF Var1 - Var4) for the mean of Var1 to Var4.</p> Signup and view all the answers

What does the INPUT function do?

<p>It converts character variables to numeric using a specified informat.</p> Signup and view all the answers

What does the PUT function do?

<p>It converts numeric variables to character using a specified format.</p> Signup and view all the answers

The concatenation operator in SAS is represented by ___.

<p>||</p> Signup and view all the answers

What is the purpose of the MDY function in SAS?

<p>It generates a SAS date value from given month, day, and year.</p> Signup and view all the answers

What do the DAY, YEAR, and MONTH functions return?

<p>DAY returns the day of the month, YEAR returns the year, and MONTH returns the month of the date.</p> Signup and view all the answers

Which functions count the number of times intervals are crossed?

<p>INTCK</p> Signup and view all the answers

What is the role of nested DO loops in SAS?

<p>Nested DO loops allow for looping within loops, requiring different index variables and corresponding END statements.</p> Signup and view all the answers

Which variables are analyzed by default in PROC MEANS?

<p>Every numeric variable in the SAS data set</p> Signup and view all the answers

What default statistics are produced by PROC MEANS?

<p>Standard Deviation</p> Signup and view all the answers

How can you choose specific statistics in PROC MEANS?

<p>Add them to the PROC MEANS statement as options.</p> Signup and view all the answers

How can you choose the number of decimal places in PROC MEANS?

<p>Use: MAXDEC = k in the PROC MEANS statement.</p> Signup and view all the answers

How do you choose variables to be analyzed in PROC MEANS?

<p>Use the VAR statement below the PROC MEANS statement.</p> Signup and view all the answers

The CLASS statement requires data to be sorted before using it in PROC MEANS.

<p>False</p> Signup and view all the answers

What is the purpose of the OUTPUT statement in PROC MEANS?

<p>To create an output data set.</p> Signup and view all the answers

Which statement is used to limit variables for frequency reports with PROC FREQ?

<p>TABLES</p> Signup and view all the answers

What is the effect of format in PROC FREQ?

<p>Use PROC FORMAT to redefine categories of values.</p> Signup and view all the answers

What is a two-way frequency report?

<p>Analyzes all possible combinations of the distinct values of two variables.</p> Signup and view all the answers

What are NOFREQ, NOPERCENT, NOROW, and NOCOL options used for in PROC FREQ?

<p>They suppress cell frequency, cell percent, row percent, and column percent respectively.</p> Signup and view all the answers

What does the ODS statement do in SAS?

<p>It allows for output to various destinations including HTML, Listing, XML, RTF, PDF, and others.</p> Signup and view all the answers

What is the syntax for creating a table of contents with the ODS statement?

<p>Use: ODS HTML BODY='body-file-specification' CONTENTS='Contents-file-specification' FRAME='Frame-file-specification';</p> Signup and view all the answers

How do you initialize an accumulator variable in SAS?

<p>Use the SUM statement.</p> Signup and view all the answers

An accumulator variable's value resets to 0 after each DATA step execution.

<p>False</p> Signup and view all the answers

How are variable lengths assigned in SAS?

<p>A numeric variable has a length of 8 bytes, while character variables are assigned based on the first occurrence in the DATA step.</p> Signup and view all the answers

What is the DROP statement used for?

<p>To drop variables that are read or created during the DATA step.</p> Signup and view all the answers

What is the purpose of the SELECT statement in SAS?

<p>To assign, create, and manage variables</p> Signup and view all the answers

What does the POINT= option do in the SET statement?

<p>It allows reading specific observations directly.</p> Signup and view all the answers

What is interleaving in SAS?

<p>Interspersing observations from two or more data sets based on common variables.</p> Signup and view all the answers

What does the RENAME= option do in SAS?

<p>It changes the name of a variable in the data set.</p> Signup and view all the answers

What is the PROC APPEND procedure used for?

<p>To append observations from one data set to another.</p> 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 with ODS 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, where Var1 - 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.

Quiz Team

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!

More Like This

SAS Program Rules and Results
17 questions
History of SAS
3 questions

History of SAS

ThrivingLouvreMuseum avatar
ThrivingLouvreMuseum
SAS Flashcards on Statistics
13 questions
Use Quizgecko on...
Browser
Browser