1
votes

I am using the following code to delete some rows from a dataset on a certain condition:

  data MK_RETURN;
    /*delete some data to solve the beta zero problem*/
    if CUM_RETURN<RMIN then delete;
  run;

However, I found out that the dataset MK_RETURN became not only empty, but also missing all the variables but CUM_RETURN and return.

Before the delete operation, the dataset contains six ~ seven variables. But after the delete operation, the dataset only contains two (empty variables), i.e. CUM_RETURN, RMIN.

What is wrong here?

The input data is something like

+--------+----------+------+--------------+--------------+-------------+----------+----------------+
| SYMBOL |   DATE   | time |  CUM_RETURN  |  return_sec  |    RMIN     |  one_M   | MK_RETURN_RATE |
+--------+----------+------+--------------+--------------+-------------+----------+----------------+
| A      | 20130108 |    1 | 0            |              | 0.00023571  | 1.90E-11 | 3.130243764    |
| A      | 20130108 |    2 |              | -0.00117855  | 0.000235988 | 1.90E-11 | 0.000274509    |
| A      | 20130108 |    3 | 0.000471976  | 0.000471976  | 0.000235877 | 1.90E-11 | 6.86083E-05    |
| A      | 20130108 |    4 |              | -0.000471754 | 0.000235988 | 1.90E-11 | 6.86036E-05    |
| A      | 20130108 |    5 | -0.000471976 | -0.000943953 | 0.000236211 | 1.90E-11 | 6.85989E-05    |
| A      | 20130108 |    6 |              | -0.002362112 | 0.000236771 | 1.90E-11 | 0              |
| A      | 20130108 |    7 | 0.000711876  | 0.001183852  | 0.000236491 | 1.90E-11 | -0.000137188   |
| A      | 20130108 |    8 |              | 0.001300698  | 0.000236183 | 1.90E-11 | 0              |
| A      | 20130108 |    9 | 0.000711876  | 0            | 0.000236183 | 1.90E-11 | 0              |
| A      | 20130108 |   10 |              | 0            | 0.000236183 | 1.90E-11 | 0.000137207    |
| A      | 20130108 |   11 | 0.000711876  | 0            | 0.000236183 | 1.90E-11 | 0.000137188    |
| A      | 20130108 |   12 |              | 0.000590458  | 0.000236044 | 1.90E-11 | 6.85848E-05    |
| A      | 20130108 |   13 | 0.000711876  | 0            | 0.000236044 | 1.90E-11 | 0              |
| A      | 20130108 |   14 |              | -0.000118022 | 0.000236072 | 1.90E-11 | -0.0003429     |
| A      | 20130108 |   15 | 0.000711876  | 0            | 0.000236072 | 1.90E-11 | -0.000068604   |
+--------+----------+------+--------------+--------------+-------------+----------+----------------+
1
Did you read the SAS log? It should say that your new dataset has only one observation and two variables. It should also say that both of the variables are uninitialized. - Tom
Yes it did say that. - Jinhua Wang
You really should consider the free SAS e-course :) - Reeza

1 Answers

6
votes

You didn't declare an input dataset (no set statement) - so you have created a new, empty dataset called MK_RETURN with two variables that were assigned as missing numerics given the absence of a definition.

Try the following (if not too late):

data MK_RETURN;
  set INPUTDATASET;  /* THIS is the line you need */
  /*delete some data to solve the beta zero problem*/
  if CUM_RETURN<RMIN then delete;
run;