程序代写代做代考 ____________________Name

____________________Name

_______________________Name

Fall 2018

5. (6 pts) The program, cowdata.for.prog1.sas reads the raw data file, cowdata.dat. In this

data set, there is a grouping variable, where 1 and 2 represent two groups of cows, one healthy

and one sick. The weight of the cows is measured at five equally spaced occasions. Sort the data

by group and look at the means to see if you can tell which group is which. Note that less

healthy cows tend to gain less weight over time.

Now, in a separate program, take this wide data set and rewrite this as a long data set. In doing

this, create two time variables,

TIME 0 1 2 3 4

and

TIMESQ 0 1 4 9 16.

These are linear and quadratic polynomials based on the time variable and could be used to fit a

straight line, a quadratic curve or a combination of both.

After you create the long data, use PROC PRINT to look at the data and show that it is correct.

Use the following commands to look at the data to plot the data and compare groups.

proc sgplot ;

reg x=time y=logwt/group=grp;

run;

6. (6 pts) I would like you to take the file potroy.corr.to.class.sas and generate three the

same three types of correlations we looked at in the R program: Pearson Product Moment

Correlation, Kendall τs, and Spearman ρs .

You can get these in PROC CORR using

PROC CORR PEARSON KENDALL SPEARMAN;

You can output data sets with each type of correlation using

PROC CORR PEARSON KENDALL SPEARMAN OUTP=POTROYP OUTK=POTROYK

OUTS=POTROYS;

I would like you generate the correlations as above which will create three new output

data sets. Then I would like you to create a new data set which includes all three types of

correlation coefficients.

If you look at any of the output files they will look like:

Obs _TYPE_ _NAME_ dep1 dep2 dep3 dep4

1 MEAN 22.1852 23.1667 24.6481 26.0926
2 STD 2.4343 2.1573 2.8176 2.7667
3 N 27.0000 27.0000 27.0000 27.0000
4 CORR dep1 1.0000 0.6256 0.7108 0.5998
5 CORR dep2 0.6256 1.0000 0.6349 0.7593
6 CORR dep3 0.7108 0.6349 1.0000 0.7950
7 CORR dep4 0.5998 0.7593 0.7950 1.0000

For example, these are the Pearsons. Notice that the names of the variables and the names of

the rows do not help matters. As a result, you will want to do something to indicate that these

correlations are Pearsons. There are a number of different ways to do this. You will also have

to consider that will allow you to merge the three data sets,

You should set each of the three types of matrices in a different DATA step using the

SET command. You should then rename the variables (e.g. dep1 becomes pearson1). Once

you create the three new data sets, you will need to merge the files. Each file has the same

descriptive statistics. You can either delete the descriptive statistics, or you can keep the

descriptive statistics in one of the three data sets and add that to the merged data set. Once you

merge the data sets, use PROC PRINT to show that you now have the three sets of correlations

in a single SAS data set.

Next, these data were broken down by GENDER. I would like you create a table that

includes the above statistics broken down by GENDER. You can either put this into a single

table or create two separate tables. Use PROC PRINT to print out the table.

7. (6 pts) I have included the data set, new.cowdata.dat. Write a SAS program to read in the

data. Make sure to use the correct informat when necessary. For the input statement make sure

that you are reading the data out of the correct columns. Probably, the simplest way to check

column locations is to open the data in a text reader and use your cursor to identify the columns.

Note that I’ve changed the column locations from the previous version of this data set. After

you read in the data, use PROC PRINT to show that you have read in the data correctly.

For the R questions, I would like you to turn in both the R script (e.g. a .R file) and the

output (either a copy of the console or the results of sink()). You can also put everything into a

Word file if you prefer. Make sure that I enough to be able to look at your program and what

the program does.

For the SAS questions, turn in the program and the output.