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

The instructions for assignment 7 of stat 321, which involves creating two permanent sas data sets, concatenating them, and generating new variables. How to use the 'in=' option with a set statement to create a new variable indicating the data set origin, and provides syntax for concatenating the data sets while keeping specific observations and creating new variables. The final data set should contain observations from both data sets, with new variables based on the original data.

Typology: Assignments

Pre 2010

Uploaded on 02/10/2009

koofers-user-l5p
koofers-user-l5p 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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.