Learning SAS? Welcome to the exclusive online community for all SAS learners.

How do i handle data with missing values.

Reply
New Contributor
Posts: 2

How do i handle data with missing values.

Hi, I'm trying to run proc corr with data that contain missing values but SAS won't run it. Is there any specific codes that I have to know in order to run this? Thank you

data bagworm;
input block s1 m1 s5 m5 lst1 lst2;
cards;

1	.	.	.	.	.	26.49
2	.	.	.	.	.	26.84
3	.	.	.	.	.	27.42
4	.	.	.	.	.	27.66
5	.	.	.	.	.	27.08
6	.	.	.	.	.	27.67
7	24	1.6	71	4.733333333	.	25.96
8	69	2.3	223	7.433333333	.	26.98
9	200	6.451612903	87	2.806451613	.	28.55
10	53	1.766666667	237	7.9	.	28.05
11	51	3.4	0	0	.	25.87
12	20	1.333333333	0	0	.	25.14
13	66	4.4	0	0	.	24.88
14	3	0.15	17	0.85	.	26.91
15	33	1.65	28	1.4	.	27.31
16	46	2.3	51	2.55	.	27.08
17	111	5.55	79	3.95	.	26.67
18	51	2.55	73	3.65	.	25.52
19	90	4.5	62	3.1	.	29.51
20	60	3	16	0.8	.	29.74
21	47	2.35	22	1.1	.	30.79
22	.	.	.	.	.	30.62
23	4	0.2	18	0.9	.	27.61
24	46	2.3	28	1.4	.	.
25	29	1.933333333	0	0	.	.
26	56	3.733333333	0	0	.	.

;
proc corr;
var block s1 m1 s5 m5 lst1 lst2;
run;
Super User
Posts: 7,764

Re: How do i handle data with missing values.

After replacing the tabs in your cards, I could run your code just fine:

data bagworm;
input block s1 m1 s5 m5 lst1 lst2;
cards;
1 . . . . . 26.49
2 . . . . . 26.84
3 . . . . . 27.42
4 . . . . . 27.66
5 . . . . . 27.08
6 . . . . . 27.67
7 24 1.6 71 4.733333333 . 25.96
8 69 2.3 223 7.433333333 . 26.98
9 200 6.451612903 87 2.806451613 . 28.55
10 53 1.766666667 237 7.9 . 28.05
11 51 3.4 0 0 . 25.87
12 20 1.333333333 0 0 . 25.14
13 66 4.4 0 0 . 24.88
14 3 0.15 17 0.85 . 26.91
15 33 1.65 28 1.4 . 27.31
16 46 2.3 51 2.55 . 27.08
17 111 5.55 79 3.95 . 26.67
18 51 2.55 73 3.65 . 25.52
19 90 4.5 62 3.1 . 29.51
20 60 3 16 0.8 . 29.74
21 47 2.35 22 1.1 . 30.79
22 . . . . . 30.62
23 4 0.2 18 0.9 . 27.61
24 46 2.3 28 1.4 . .
25 29 1.933333333 0 0 . .
26 56 3.733333333 0 0 . .
;
run;

proc corr;
var block s1 m1 s5 m5 lst1 lst2;
run;

Log:

16         data bagworm;
17         input block s1 m1 s5 m5 lst1 lst2;
18         cards;

NOTE: The data set WORK.BAGWORM has 26 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      
45         ;

46         run;
47         
48         proc corr;
49         var block s1 m1 s5 m5 lst1 lst2;
50         run;

NOTE: The PROCEDURE CORR printed page 1.
NOTE: PROCEDURE CORR used (Total process time):
      real time           0.03 seconds
      cpu time            0.02 seconds
 

Results:

                                             The CORR Procedure

               7  Variables:    block    s1       m1       s5       m5       lst1     lst2     


                                             Simple Statistics

         Variable           N          Mean       Std Dev           Sum       Minimum       Maximum

         block             26      13.50000       7.64853     351.00000       1.00000      26.00000
         s1                19      55.73684      43.86322          1059       3.00000     200.00000
         m1                19       2.70886       1.64975      51.46828       0.15000       6.45161
         s5                19      53.26316      68.93704          1012             0     237.00000
         m5                19       2.24069       2.41399      42.57312             0       7.90000
         lst1               0             .             .             .             .             .
         lst2              23      27.40652       1.58728     630.35000      24.88000      30.79000


                                     Pearson Correlation Coefficients 
                                        Prob > |r| under H0: Rho=0 
                                          Number of Observations

                block            s1            m1            s5            m5          lst1          lst2

  block       1.00000      -0.23618      -0.08203      -0.51554      -0.52162        .            0.41446
                             0.3303        0.7385        0.0239        0.0220         .            0.0493
                   26            19            19            19            19             0            23

  s1         -0.23618       1.00000       0.90349       0.28282       0.24710        .            0.25755
               0.3303                      <.0001        0.2407        0.3078         .            0.3355
                   19            19            19            19            19             0            16

  m1         -0.08203       0.90349       1.00000       0.05006       0.04570        .            0.12566
               0.7385        <.0001                      0.8387        0.8526         .            0.6429
                   19            19            19            19            19             0            16

  s5         -0.51554       0.28282       0.05006       1.00000       0.96460        .            0.10596
               0.0239        0.2407        0.8387                      <.0001         .            0.6961
                   19            19            19            19            19             0            16

  m5         -0.52162       0.24710       0.04570       0.96460       1.00000        .            0.06882
               0.0220        0.3078        0.8526        <.0001                       .            0.8001
                   19            19            19            19            19             0            16

  lst1         .             .             .             .             .             .             .     
                .             .             .             .             .             .             .    
                    0             0             0             0             0             0             0

  lst2        0.41446       0.25755       0.12566       0.10596       0.06882        .            1.00000
               0.0493        0.3355        0.6429        0.6961        0.8001         .                  
                   23            16            16            16            16             0            23

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 2

Re: How do i handle data with missing values.

Posted in reply to KurtBremser

@KurtBremser thanks for the reply. That is so weird haha. i should try it again. thanks Smiley Happy

Ask a Question
Discussion stats
  • 2 replies
  • 268 views
  • 1 like
  • 2 in conversation