Question

In: Statistics and Probability

/*Question 3: The following data contains five columns (variables) and five rows (observations). First, read the...

/*Question 3: The following data contains five columns (variables) and five rows (observations). First, read the data into SAS to create a data set. Notice that the first, third, and the fifth variable have missing values. Please replace the missing values of the first, third, and fifth variable with 30, 40, and 50, respectively. Next, for all the variables, if a value is at least 100, make an adjustment to the value such that its new value is equal to its old value minus 50. 15 20 . 35 55 60 50 75 100 80 . 40 100 200 . 25 50 79 120 45 80 150 . 120 35 */

Solutions

Expert Solution

All the SAS code will be indented ( space left on the left margin), and the explanation and comments will be non-indented.

We are first required to create the dataset. I will call the data set 'data_set' and call the columns 'first', 'second', 'third', 'fourth' and 'fifth'. The following code can create a dataset:

DATA data_set;
input first second third fourth fifth;
datalines;
15 20 . 35 55
60 50 75 100 80
. 40 100 200 .
25 50 79 120 45
80 150 . 120 35
;

Next, we are required to replace the missing values in the first column with 30, third column with 40 and fifth column with 50. The following code can replace missing values:

DATA data_set;
set data_set;
if first=. then do;
first=30;
end;

DATA data_set;
set data_set;
if third=. then do;
third=40;
end;

DATA data_set;
set data_set;
if fifth=. then do;
fifth=50;
end;

Next, we are required to subtract 50 from the values of the dataset, if the values are 100 or greater than 100. I have looped through all the columns, and if the values in those columns was 100 or above, I have deducted 50. The following code can do the looping and the subtraction:

DATA data_set;
set data_set;
array cols first -- fifth;
do over cols;
if cols>100|cols=100 then do;
cols= cols-50;
end;
end;

I hope this helped you, and solved the problem at hand. Please let me know if you have a doubt or spot an error. Happy learning!


Related Solutions

"Create a program that displays a table consisting of four rows and five columns. The first...
"Create a program that displays a table consisting of four rows and five columns. The first column should display the numbers 1 through 4. The second and sub-sequent columns should display the result of multiplying the number in the first column by the numbers 2 through 5. If necessary, create a new project named Introductory14 Project, and save it in the Cpp8\Chap08 folder. Enter the C++ instructions into a source file named Introductory14.cpp. Also enter appropriate comments and any additional...
1 – Create a webpage that contains a table with exactly three rows and two columns....
1 – Create a webpage that contains a table with exactly three rows and two columns. The first row will contain a table heading containing the name of a US National Park, that spans across all columns. Hint: use the colspan attribute inside the opening th tag Give the table heading an onmouseover that will change the text of the heading when it is moused over to read My Favorites Park! (Hint: use innerHTML). Use onmouseout to change it back....
1 – Create a webpage that contains a table with exactly three rows and two columns....
1 – Create a webpage that contains a table with exactly three rows and two columns. The first row will contain a table heading containing the name of a US National Park, that spans across all columns. Hint: use the colspan attribute inside the opening th tag Give the table heading an onmouseover that will change the text of the heading when it is moused over to read My Favorites Park! (Hint: use innerHTML). Use onmouseout to change it back....
The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown in...
The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown in Figure 8-23. The Lo Shu Magic Square has the following properties: l The grid contains the numbers 1 through 9 exactly. l The sum of each row, each column, and each diagonal all add up to the same number. This is shown in Figure 8-24. In a program, you can simulate a magic square using a two-dimensional array. Design a program that initializes a...
In the following data set, the columns indicate young adults’ smoking habit, while the rows indicate...
In the following data set, the columns indicate young adults’ smoking habit, while the rows indicate their exercise status. Please conduct a hypothesis to determine whether smoking habit and exercise status are associated. Choose α = 0.05. (Please make sure to check assumptions, if assumptions are not met, you may stop). this q is for a biostatistical subject. Smoking Habit Exercise Status Frequent Some None Total Never 98 86 35 219 Occasion 29 47 23 99 Regular 17 9 17...
I need a copy of organized data in a spreadsheet with rows and columns labeled, can...
I need a copy of organized data in a spreadsheet with rows and columns labeled, can anyone help me with this please? I am doing a made up experiment where I see if eating vegetarian diets makes someone healthier. I am ‘supposed’ to find a group of people at school willing to participate and change their diet, pull their names from a jar, and randomly assign who will try the vegetarian diet and who’s diet will remain the same that...
1. For a data set with 3 variables and 3 observations, suppose Xbar, the sample mean...
1. For a data set with 3 variables and 3 observations, suppose Xbar, the sample mean vector is [5, 3, 4]’. Let b’ = (1 1 1) and c’ = (1 2 -3). The sample covariance matrix is given as, S = ( 13 −3.5 1.5;  −3.5 1 −1.5 ; 1.5 −1.5 3 ) (a) Find the sample mean and variance for b’X and c’X. (b) Find the sample mean and variance for c’X. (c) Find the covariance between b’X and...
Write a script to display the following patterns on the screen. Number of rows and columns...
Write a script to display the following patterns on the screen. Number of rows and columns are taken from the command arguments; if they are missing, set default to 3 (rows) and 4 (columns). Hint: you will use a nested loop. **** **** **** a) Display the source code in an editor (#4-11) b) Execute your script in the terminal, and display the command and the result (#4-12)
In a regression analysis of a first-order model involving 3 predictor variables and 25 observations, the...
In a regression analysis of a first-order model involving 3 predictor variables and 25 observations, the following estimated regression equation was developed. = 12 - 18x1 + 4x2 + 15x3 Also, the following standard errors and the sum of squares were obtained. sb1 = 3 sb2 = 6 sb3 = 7 SST = 4900 SSE = 1296 If we are interested in testing for the significance of the relationship among the variables (i.e., significance of the model), the critical value...
Consider the following game. Ann chooses rows, and Bob chooses columns. [12 marks] LMR 3 4...
Consider the following game. Ann chooses rows, and Bob chooses columns. [12 marks] LMR 3 4 2 0 1 3 3 2 4 4 4 0 0 2 1 1 0 1 U C D (a) Find all pure strategy Nash Equilibria. (b) Find the set of Rationalizable strategies for each player. Find a dominating strategy for each deletion. (c) Is there a Nash equilibrium in which Bob puts strictly positive probability on L and M but none on R?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT