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?
How do you create a new numeric column in a DATA step?
How do you create a new numeric column in a DATA step?
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?
What does the DROP
statement achieve in a DATA step?
What does the DROP
statement achieve in a DATA step?
Signup and view all the answers
Which statement correctly formats a column in the DATA step?
Which statement correctly formats a column in the DATA step?
Signup and view all the answers
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?
Signup and view all the answers
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?
Signup and view all the answers
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?
Signup and view all the answers
Signup and view all the answers
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.
Related Documents
Description
This quiz focuses on data manipulation techniques using SAS programming. Topics include filtering data, formatting columns, creating new columns, and utilizing functions for summary statistics. Test your knowledge on how to effectively manage and analyze datasets in SAS.