Podcast
Questions and Answers
What is the purpose of the WHERE
statement in the DATA step?
What is the purpose of the WHERE
statement in the DATA step?
- To create new columns in the output data set.
- To rename the input data set.
- To format existing columns in the output data set.
- To filter rows based on a specified condition. (correct)
How do you create a new numeric column in a DATA step?
How do you create a new numeric column in a DATA step?
- DATA output-table; SET input-table; col-name = expression; RUN;
- DATA output-table; SET input-table; LENGTH new-column $ length; RUN;
- DATA output-table; SET input-table; new-column = expression; RUN; (correct)
- DATA output-table; SET input-table; FORMAT col-name format; RUN;
What function would you use to calculate the maximum of the provided values?
What function would you use to calculate the maximum of the provided values?
- MEAN(arguments)
- MAX(num1, num2...) (correct)
- N(arguments)
- SUM(arguments)
What does the DROP
statement achieve in a DATA step?
What does the DROP
statement achieve in a DATA step?
Which statement correctly formats a column in the DATA step?
Which statement correctly formats a column in the DATA step?
How do you define the length of a character column in a DATA step?
How do you define the length of a character column in a DATA step?
Which function is used to concatenate character strings while removing leading and trailing blanks?
Which function is used to concatenate character strings while removing leading and trailing blanks?
What is the result of using the SUM
function with missing values in its arguments?
What is the result of using the SUM
function with missing values in its arguments?
Flashcards
Creating a dataset copy
Creating a dataset copy
Creates a copy of an existing dataset, providing a new dataset without altering the original.
Filtering rows in a dataset
Filtering rows in a dataset
Filters rows in a dataset based on a specified condition.
Specifying columns in a dataset
Specifying columns in a dataset
Specifies which columns to include in a new dataset, excluding others.
Creating new columns
Creating new columns
Signup and view all the flashcards
Summary statistics functions
Summary statistics functions
Signup and view all the flashcards
Character functions
Character functions
Signup and view all the flashcards
Date functions
Date functions
Signup and view all the flashcards
Creating character columns
Creating character columns
Signup and view all the flashcards
Study Notes
Reading and Filtering Data
- Create a copy of data using
DATA output-table; SET input-table; RUN;
- Filter rows using
WHERE expression
in aDATA
step. Example:DATA output-table; SET input-table; WHERE age > 25; RUN;
- Specify columns in the output using
DROP
orKEEP
. Example:DROP col1 col2;
orKEEP col3 col4;
Formatting Columns
- Format columns in a
DATA
step usingFORMAT
. Example:FORMAT col-name format;
Computing New Columns
- Create new columns using expressions. Example
new-column = expression;
- SAS automatically assigns type and length to new columns. Character columns' length is based on the assigned string length.
- Character strings must be quoted and are case-sensitive.
Using Functions
- Calculate summary statistics using functions (e.g., SUM, MEAN, MIN, MAX, N). Exclude missing values by default.
- Character functions like
UPCASE
,LOWCASE
,PROPCASE
are available. - Date functions extract parts of dates (e.g.,
MONTH
,YEAR
,DAY
). CATS
concatenates strings.SUBSTR
extracts substrings.MDY
creates a date from month, day, year values.TODAY
returns the current date as a SAS date.- Use functions within expressions, like,
new-column = function(arguments);
Conditional Processing
- Use
IF-THEN
statements for simple conditions. Example:IF age > 65 THEN DO; statement; END;
- Use
IF-THEN-ELSE
for more complex conditions. Example:IF age > 65 THEN DO; expensive; END; ELSE DO; cheap END;
- Use
IF-THEN-DO
for multiple statements based on a condition. Example:IF score > 90 THEN DO; print 'Excellent'; grade = 'A'; END;
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.