part 2

  1. Address this question as a comment, clearly labeled as question 1 in your SAS code file. Suppose the following SAS data set called PARTICIPANTS is read in a DATA step using a SET statement as well as BY Gender Height. Explain the difference between FIRST.Gender and FIRST.Height, and indicate which observations will have a value of 1 for these automatic variables.  Code is not required to answer this question.

Name

Gender

Height

JoAnn

F

64

Jane

F

66

Joyce

F

68

David

M

69

Stan

M

70

Jim

M

71

Bob

M

71

  1. (continued from previous workshop) The local school district wants to survey all sixth-grade students and their school aged siblings. There are three different types of surveys: one for the sixth graders, one for their younger siblings, and one for their older siblings. The SAS data set called SCHOOLSURVEY contains data for all sixth graders in the three middle schools in the district (Rachael Carson, Green Valley, and Redwood Grove). The data set also includes data for all their siblings attending schools in the district, which can be linked back to the sixth grader by Family_ID. 
    1. For each sixth grader, add variables to your data set for the age difference between the sixth grader and their youngest sibling, and the age difference between the sixth grader and their oldest sibling.  
    2. For each school, compute the average, minimum, and maximum age difference between the sixth graders and their youngest and oldest siblings. Be sure to show the complete names for the schools.
  2. The workbook Chapter6WSdata.xlsx contains a worksheet called variable types.
    1. Using proc import, read into a SAS data table called raw.
    2. The code below converts the variables Group and ID from character to numeric and numeric to character, respectively. Copy this code into your SAS code file.

data converted;

   set raw;

   *example: convert character variable Group to numeric variable numGroup;

   numGroup = input(Group,2.);

   *example: convert numeric variable ID to character variable ID_txt;

   ID_txt=put(ID, 3.);

run;

    1. Add code to convert the character variable Dollars to the numeric variable numDollars
    2. Add code to convert the numeric variable Account to the character variable Account_txt;
    3. Use proc contents to confirm the conversion of the variables.
    4. What is the difference in the type of format to be specified in the input and put functions?
  1. Complete the exercises in the file “07 Common Merge Problems Workshop.sas” with questions embedded in the SAS code.