Docsity

SAS Assignment 7: Concatenating Two Data Sets and Creating New Variables - Prof. James Dav, Assignments of Statistics

Toggle sidebar
bg1
STAT 321 - Assignment 7
As usual, send me copies of your programs and the resulting permanent SAS data set. Turn in a
copy of the SAS program and the printout.
The "in=" option to a set statement will create a new variable that will have the value of 1 if the
observation comes from the data set specified in the set statement. The syntax for concatenating
two data sets (names one and two) is as follows:
set one(in=inone) two;
For this case, each observation from data set one will have a variable with the name "inone" that
has a value one; otherwise the value of the variable will be set to a missing value. This variable
is in the program data vector; so it is available for use in calculations. However, it is not written
to the data set. Ask me for clarification if you have any questions about this new command.
Create a permanent SAS data set called “one” that contains the three variables X, Y, and Z and
contains the following seven observations.
1 2 3 1 3 6 1 7 8 2 3 -1 2 4 0 2 6 8 3 4 1
Create a permanent SAS data set called “two” that contains the two variables A and B and
contains the following five observations.
A 6.67 B 7.34 C 4.91 D 3.38 C -0.6
Create a new permanent SAS data set that concatenates data sets one and two subject to the
following:
1. Keep the observations for which X ≠ 1.
2. If the observation comes form data set one, then compute a new variable W which is
the difference between Y and Z (i.e. W = Y – Z); otherwise, W = 0.
3. Create a new variable that is variable B rounded to the nearest 0.5.
4. The final SAS data set does not contain the variables Y, Z, nor B.
Print the resulting data set.

Partial preview of the text

Download SAS Assignment 7: Concatenating Two Data Sets and Creating New Variables - Prof. James Dav and more Assignments Statistics in PDF only on Docsity!

STAT 321 - Assignment 7

As usual, send me copies of your programs and the resulting permanent SAS data set. Turn in a copy of the SAS program and the printout.

The "in=" option to a set statement will create a new variable that will have the value of 1 if the observation comes from the data set specified in the set statement. The syntax for concatenating two data sets (names one and two) is as follows:

set one(in=inone) two;

For this case, each observation from data set one will have a variable with the name "inone" that has a value one; otherwise the value of the variable will be set to a missing value. This variable is in the program data vector; so it is available for use in calculations. However, it is not written to the data set. Ask me for clarification if you have any questions about this new command.

Create a permanent SAS data set called “one” that contains the three variables X, Y, and Z and contains the following seven observations.

1 2 3 1 3 6 1 7 8 2 3 -1 2 4 0 2 6 8 3 4 1

Create a permanent SAS data set called “two” that contains the two variables A and B and contains the following five observations.

A 6.67 B 7.34 C 4.91 D 3.38 C -0.

Create a new permanent SAS data set that concatenates data sets one and two subject to the following:

  1. Keep the observations for which X ≠ 1.
  2. If the observation comes form data set one, then compute a new variable W which is the difference between Y and Z (i.e. W = Y – Z); otherwise, W = 0.
  3. Create a new variable that is variable B rounded to the nearest 0.5.
  4. The final SAS data set does not contain the variables Y, Z, nor B.

Print the resulting data set.