Question: 2.1Write SAS statements to create a new SAS data set called statisticians and add the following variables using the specified variable names. Be sure to
2.1Write SAS statements to create a new SAS data set calledstatisticiansand add the following variables using the specified variable names. Be sure to precede each part of the data step with a comment giving the question name and a brief description of the task.For example:/* 3.3a: getting the first names */ .
a.The first name of the statistician. Call itfirstwith a length of 20.
b.The last name of the statistician (the last word in the name, hence the word 'last name')) Call itlastwith a length of 20. Note that some the statisticians have two names, some three and some four. This should be the second if there are two, the third if there are three and the fourth if there are four, etc.
c.Using the variablesfirstandlastas computed above, compute the statistician's name in the form first, one space, last. Call itnewfulland assign an appropriate length. Use thestripfunction to take care of leading and trailing blanks when defining this variable.
d.Using the variablesfirstandlastas computed above, compute the statistician's name in the form last, a comma, one space, first.Call itlastfirstand assign an appropriate length. Ensure that there are no leading or trailing blanks in this variable.
e.Using the variablesfirstandlastcomputed above, compute the statistician's name in the form first initial, a period, one space, last name. Call itfilastand assign an appropriate length. There must be no leading blanks.)
f.Create a variablemiddlewhich is the statistician'sfirstmiddle name if they have one or more and is blank if there is no middle name. Assign the appropriate length. Examples: For George Edward Pelham Box it must Edward, for Ronald Aylmer Box it must be Aylmer and for Karl Pearson it must be blank.
g.Compute a (numeric) variable calledfirsttothat gives the location of the first occurrence of the character string 'to' in the text and is zero if there is no first occurrence of'to'in the text. Respect case here. I.e. the strings'To','tO', or any other combination with upper case letters in the spelling of this word arenotwanted. It is acceptable for the string to occur as part of another word. Note: Do loops arenotneeded here.
h.Create a character variableLastSentenceof length 400 which is the last sentence of the text as separated by periods, question marks or exclamation points. There should be no leading blanks. The ending punctuation may be omitted here. The last sentence mustnotbeblank.Note: Do loops arenotneeded here.
i.Create a character variable of length 15 calledborndied.Then compute the following: It should be yearborn-yeardied if both values are present and yearborn - if the statistician is still alive. Examples: For Fisherborndiedis1890-1962andBox it is1919-.Note: Sometimes born and died are given in the form mm/dd/yyyy and sometimes yyyy. You need to handle both cases.Note: The not equal relation can be specified using ^= or ne in case you need it.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
