BookmarkSubscribeRSS Feed
newbie123
Calcite | Level 5
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?
2 REPLIES 2
newbie123
Calcite | Level 5
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;
Paige
Quartz | Level 8
> 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?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 807 views
  • 0 likes
  • 2 in conversation