New Contributor
Posts: 2

# Missing Data Analysis

Very new to this, need to formulate a missing value pattern table in SAS. Let me explain.

data test;
input landval improval totval salepric saltoapr city \$6. season \$8. truefalse;
datalines;
30000 64831 94831 118500 1.25 A spring 1
30000 50765 80765 93900 . winter 0
46651 18573 65224 . 1.16 B 1
45990 91402 . 184000 1.34 C winter 1
42394 . 40575 168000 1.43 0
. 3351 51102 169000 1.12 D winter 0
63596 2182 65778 . 1.26 E spring 1
56658 53806 10464 255000 1.21 0
51428 72451 . . 1.18 F spring 0
93200 . 4321 422000 1.04 1
76125 78172 54297 290000 1.14 G winter 1
. 61934 16294 237000 1.10 H spring 0
65376 34458 . 286500 1.43 winter 1
42400 . 57446 . . K 0
40800 92606 33406 168000 1.26 S 0
;
run;

There are missing values in the above table, except for the column truefalse. If i create a missing pattern data like this

data miss_pattern (drop=i);
set test;
array mynum(*) _numeric_;
do i=1 to dim(mynum);
if mynum(i) =. then mynum{i}=1;
else mynum(i)=0;
end;
array mychar(*) \$ _character_;
do i=1 to dim(mychar);
if mychar(i) ="" then mychar{i}=1;
else mychar(i)=0;
end;
run;
proc freq data=miss_pattern;
tables landval*improval*totval*salepric*saltoapr*city*season /list;
run;

I get the desired output, except i would like to add a column in this table called "number of truefalse = 1"

which would tell me how many combinations had the value 1 for that column in the original table. Any minor changes to the code that I can make?
New Contributor
Posts: 2

## Re: Missing Data Analysis

Perhaps these datalines will work better.

30000 64831 94831 118500 1.25 A spring 1
30000 50765 80765 93900 . winter 0
46651 18573 65224 . 1.16 B 1
45990 91402 . 184000 1.34 C winter 1
42394 . 40575 168000 1.43 0
. 3351 51102 169000 1.12 D winter 1
63596 2182 65778 . 1.26 E spring 1
56658 53806 10464 255000 1.21 0
51428 72451 . . 1.18 F spring 1
93200 . 4321 422000 1.04 0
76125 78172 54297 290000 1.14 G winter 1
. 61934 16294 237000 1.10 H spring 1
65376 34458 . 286500 1.43 winter
42400 . 57446 . . K
40800 92606 33406 168000 1.26 S
;
run;
Super Contributor
Posts: 281

## Re: Missing Data Analysis

> I get the desired output, except i would like to add
> a column in this table called "number of truefalse =
> 1"
>
> which would tell me how many combinations had the
> value 1 for that column in the original table. Any
> minor changes to the code that I can make?

"Combinations"?? of what? (Do you mean "combinations" in the statistical sense, e.g. how many ways can I choose 5 objects out of 7?)

Does truefalse or these "combinations" have anything to do with your missings?
Discussion stats
• 2 replies
• 165 views
• 0 likes
• 2 in conversation