Ch 9 and 10

  1. T/F: SAS converts all dates to equal the number of days from January 1, 1960
    True
  2. T/F: The today() function in SAS returns the current day's date.
    True
  3. Which of the following statements correctly computes *Age* in years at time of visit, given DOB and VisitDate?




    C) Age=yrdif(DOB, VisitDate);

    The YRDIF function computes the difference in years between two dates
  4. Which program reads two data sets named FACULTY and STAFF and writes them to a new (combined) data set called DIRECTORY?




    B) data directory; set faculty staff; run;
  5. What must be true before two data sets can be merged in SAS using a by statement?




    D) The two data sets must be sorted according to the variable in the BY statement

    When merging with a by statement, SAS requires the individual data sets to be sorted first, according the variable in the BY statement. That variable is common to the individual data sets
  6. Which program reads two data sets named DAILY_TEMPERATURE and DAILY_RAIN and writes them to a new (combined) data set called WEATHER using the merge statement?




    C) data WEATHER; merge DAILY_TEMPERATURE DAILY_RAIN; by date_value; run;
  7. What variable is the data set sorted by in this proc sort?

    proc sort data=business;
    by department;
    run;




    D) department
  8. If the dataset marbles contains the variables red, blue, orange, and yellow, what variables will be in the dataset games after the following code has run?

    data games;
    set marbles;
    keep red yellow;
    run;




    D) red and yellow
  9. If the dataset marbles contains the variables red, blue, orange and yellow, what variables will be in the dataset games after the following code has run?
    data games(drop=red blue orange);
    set marbles;
    run;




    B) yellow
  10. If the dataset marbles contains the variables red, blue, orange, yellow what variables will be in the dataset games after the following code has run?
    data games(rename=(blue=navy));
    set marbles;
    run;




    A) red, orange, yellow and navy
  11. Before combining data sets, what must be done first?
    sort the data using PROC SORT
  12. What are the two ways we learned to combine datasets in SAS
    • Using the SET statement
    • Using a MERGE statement
  13. What happens when the SET statement is used to combine data?
    observations are stacked on top of each other

    The two datasets being combined do not need to have the same set of variables, but variables of the same name should be of the same type (i.e. character or numeric)
  14. How is variable length determined when combining data using SET?
    each variable has the length of the first dataset the variable appeared in
  15. What proc step is needed for the datastep merge?
    Proc Sort

    • sort data by a specific variable
    • if you want to sort highest to lowest, the keyword DESCENDING needs to be put before the variable

    • proc sort data=work.data;
    • by descending weight length1;
    • run;
  16. How does SAS store dates?
    SAS stores all dates as numbers, specifically the number of days since January 1, 1960
  17. How do each of these formats modify the date March 25, 2019?
    mmddyy10=
    mmddyy8=
    date9=
    • mmddyy10= 03/25/2019
    • mmddyy8= 03/25/19
    • date9=25Mar2019
  18. Which function computes the number of years between two dates?
    The YRDIF date function
  19. Which function will give you today's date?
    TODAY
Author
saucyocelot
ID
358421
Card Set
Ch 9 and 10
Description
Quiz six and ppts covering ch 9 and 10
Updated