Data Preparation in SAS
9 Questions
0 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 is the purpose of the statement 'KEEP col-name;' in a DATA step?

  • To rename a column
  • To include specific columns in the output (correct)
  • To drop all columns except the specified one
  • To exclude specific columns from the output
  • What will the function SUM(num1, num2,...) do in a DATA step?

  • Calculate the median of the variables
  • Ignore missing values and calculate the sum (correct)
  • Count the number of nonmissing values
  • Calculate the maximum value among the variables
  • In the expression 'new-column = expression;' what must the expression yield for a newly declared column?

  • A value that matches the existing column type
  • Any valid type; SAS will auto-define attributes (correct)
  • A character string only
  • A numeric value only
  • What does the LENGTH statement do when creating a character column?

    <p>Defines the storage length for a character variable</p> Signup and view all the answers

    What will the function LOWCASE(char1) do to a character string?

    <p>Change all characters to lowercase</p> Signup and view all the answers

    Which DATA step statement is used to filter rows based on a condition?

    <p>WHERE expression;</p> Signup and view all the answers

    What is the result of using the MAX(num1, num2,...) function?

    <p>Returns the highest nonmissing value among the specified variables</p> Signup and view all the answers

    When creating a new numeric column, what default length does SAS assign to it?

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

    Signup and view all the answers

    Study Notes

    Preparing Data in SAS

    • Reading and Filtering Data:

      • Create a copy of data using DATA output-table; RUN; SET input-table;
      • Filter rows using DATA output-table; RUN; SET input-table; WHERE expression;
      • Specify columns for the output dataset with DROP or KEEP in the DATA step.
    • Specifying Columns:

      • Include or exclude columns using DROP and KEEP statements.
      • Example: DROP col-name <col-name>; or KEEP col-name <col-name>;
    • Formatting Columns:

      • Format columns within the DATA step using FORMAT statement.
      • Example: FORMAT col-name format;
    • Computing New Columns:

      • Create new columns using expressions.
      • Example: new-column = expression; in the DATA step.
      • The column name to create or update is on the left. The expression for computation is on the right.
      • New numeric columns are 8 characters long.
      • Character columns automatically adjust length to the value assigned length. Character strings must be quoted and are case sensitive.
    • Example using functions: -Example : LENGTH char-column $ length; -Calculates summary stats (ignoring missing values): function(argument1, argument2, ...)

    • Functions:

      • Calculates common functions like sum, mean, median, range, min, max, count (non-missing and missing).
      • Character functions include changing case (upper/lower/proper) and concatenation.
      • Date functions extract values (month, year, day, weekday, quarter) or create SAS dates.

    Conditional Processing

    • IF-THEN:

      • Execute a statement if a condition is met.
      • IF expression THEN statement;
    • IF-THEN-ELSE:

      • Execute one statement if a condition is true and another if it's false.
      • IF expression THEN statement; ELSE statement;
    • IF-THEN-DO:

      • Execute multiple statements if a condition is true.
      • IF expression THEN DO; <statements>; END;
    • Example of using IF-THEN-ELSE and IF-THEN-DO.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    This quiz focuses on preparing data in SAS, covering essential techniques such as reading, filtering, and formatting datasets. You will learn how to manipulate columns by including or excluding them and computing new columns using expressions. Test your knowledge on these fundamental SAS data preparation skills.

    More Like This

    Clinical Research SAS Programming
    5 questions

    Clinical Research SAS Programming

    SeamlessLapisLazuli4419 avatar
    SeamlessLapisLazuli4419
    SAS Programming Quiz
    48 questions

    SAS Programming Quiz

    MemorableChrysoprase4817 avatar
    MemorableChrysoprase4817
    Use Quizgecko on...
    Browser
    Browser