Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- More than 50 variables using proc freq

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 07-29-2019 04:21 PM
(1169 views)

Hello all,

I am fairly new to SAS. I am attempting to create a missing data matrix, but I am running into this while using PROC FREQ:

ERROR: N-way tables disallowed for N>50.

I was thinking of simply dividing that part of the code into 2 separate steps, but then the final missing count I am looking for would be off in the resulting tables. Is there a way to run this procedure with more than 50 variables at a time?

This is the code I am using...

/* Missing data matrix */

data psm; set psm;

array ori{*} age dxage rheumdx diseaseactivity web_gen

web_rheum eligibility visit_fb_r visit_tw_r visit_ig_r

visit_bl_r visit_oth_r view_fb_r view_tw_r view_ig_r

view_bl_r view_oth_r viewreason1_r viewreason2_r viewreason3_r

viewreason4_r viewreason5_r viewreason6_r viewreason7_r viewreason8_r

viewreason9_r viewreason10_r viewreason11_r post_fb_r post_tw_r

post_ig_r post_bl_r post_oth_r dx_specific_accnt_r postrheum_anon_r

postreason1_r postreason2_r postreason3_r postreason4_r postreason5_r

postreason6_r result1_r result2_r result3_r result4_r

result5_r result6_r result7_r discuss_rheum_r discuss_family_r

discuss_child_r nopostreason1 nopostreason2 nopostreason3 nopostreason4

nopostreason5 reasonshare1 reasonshare2 reasonshare3 reasonshare4

c_global1 c_global2 c_global3 c_global4 c_global5

c_global6 c_global7 p_global1 p_global2 p_global3

p_global4 p_global5 p_global6 p_global7 p_global8

p_global9 p_global10 p_informational1 p_informational2 p_informational3

p_informational4 p_informational5 p_informational6 p_informational7 p_informational8;

array ind{*} xx1 xx2 xx3 xx4 xx5 xx6 xx7 xx8 xx9 xx10

xx11 xx12 xx13 xx14 xx15 xx16 xx17 xx18 xx19 xx20

xx21 xx22 xx23 xx24 xx25 xx26 xx27 xx28 xx29 xx30

xx31 xx32 xx33 xx34 xx35 xx36 xx37 xx38 xx39 xx40

xx41 xx42 xx43 xx44 xx45 xx46 xx47 xx48 xx49 xx50

xx51 xx52 xx53 xx54 xx55 xx56 xx57 xx58 xx59 xx60

xx61 xx62 xx63 xx64 xx65 xx66 xx67 xx68 xx69 xx70

xx71 xx72 xx73 xx74 xx75 xx76 xx77 xx78 xx79 xx80

xx81 xx82 xx83 xx84 xx85;

do i=1 to dim(ori);

if ori{i} in (999,.) then ind{i}=0; else ind{i}=1;

end;

run;

proc freq data=psm noprint; tables

xx1*xx2*xx3*xx4*xx5*xx6*xx7*xx8*xx9*xx10*xx11*xx12*xx13*xx14*xx15*

xx16*xx17*xx18*xx19*xx20*xx21*xx22*xx23*xx24*xx25*xx26*xx27*xx28*xx29*xx30*

xx31*xx32*xx33*xx34*xx35*xx36*xx37*xx38*xx39*xx40*xx41*xx42*xx43*xx44*xx45*

xx46*xx47*xx48*xx49*xx50*xx51*xx52*xx53*xx54*xx55*xx56*xx57*xx58*xx59*xx60*

xx61*xx62*xx63*xx64*xx65*xx66*xx67*xx68*xx69*xx70*xx71*xx72*xx73*xx74*xx75*

xx76*xx77*xx78*xx79*xx80*xx81*xx82*xx83*xx84*xx85

/ missing norow nocol nopercent

out=psm_miss; run;

proc print data=psm_miss; run;

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Yea it will show you the frequency and proportions.

The third example here provides a good example of what it will look like

7 REPLIES 7

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You're looking for missing across all variables? For each row or all possible combinations?

Can you make a smaller example, say 5 variables and show what your input data looks like and output data?

I have some macros that do missing but I don't think it's quite what you're looking for?

@_see wrote:

Hello all,

I am fairly new to SAS. I am attempting to create a missing data matrix, but I am running into this while using PROC FREQ:

ERROR: N-way tables disallowed for N>50.

I was thinking of simply dividing that part of the code into 2 separate steps, but then the final missing count I am looking for would be off in the resulting tables. Is there a way to run this procedure with more than 50 variables at a time?

This is the code I am using...

/* Missing data matrix */

data psm; set psm;

array ori{*} age dxage rheumdx diseaseactivity web_gen

web_rheum eligibility visit_fb_r visit_tw_r visit_ig_r

visit_bl_r visit_oth_r view_fb_r view_tw_r view_ig_r

view_bl_r view_oth_r viewreason1_r viewreason2_r viewreason3_r

viewreason4_r viewreason5_r viewreason6_r viewreason7_r viewreason8_r

viewreason9_r viewreason10_r viewreason11_r post_fb_r post_tw_r

post_ig_r post_bl_r post_oth_r dx_specific_accnt_r postrheum_anon_r

postreason1_r postreason2_r postreason3_r postreason4_r postreason5_r

postreason6_r result1_r result2_r result3_r result4_r

result5_r result6_r result7_r discuss_rheum_r discuss_family_r

discuss_child_r nopostreason1 nopostreason2 nopostreason3 nopostreason4

nopostreason5 reasonshare1 reasonshare2 reasonshare3 reasonshare4

c_global1 c_global2 c_global3 c_global4 c_global5

c_global6 c_global7 p_global1 p_global2 p_global3

p_global4 p_global5 p_global6 p_global7 p_global8

p_global9 p_global10 p_informational1 p_informational2 p_informational3

p_informational4 p_informational5 p_informational6 p_informational7 p_informational8;

array ind{*} xx1 xx2 xx3 xx4 xx5 xx6 xx7 xx8 xx9 xx10

xx11 xx12 xx13 xx14 xx15 xx16 xx17 xx18 xx19 xx20

xx21 xx22 xx23 xx24 xx25 xx26 xx27 xx28 xx29 xx30

xx31 xx32 xx33 xx34 xx35 xx36 xx37 xx38 xx39 xx40

xx41 xx42 xx43 xx44 xx45 xx46 xx47 xx48 xx49 xx50

xx51 xx52 xx53 xx54 xx55 xx56 xx57 xx58 xx59 xx60

xx61 xx62 xx63 xx64 xx65 xx66 xx67 xx68 xx69 xx70

xx71 xx72 xx73 xx74 xx75 xx76 xx77 xx78 xx79 xx80

xx81 xx82 xx83 xx84 xx85;

do i=1 to dim(ori);

if ori{i} in (999,.) then ind{i}=0; else ind{i}=1;

end;

run;

proc freq data=psm noprint; tables

xx1*xx2*xx3*xx4*xx5*xx6*xx7*xx8*xx9*xx10*xx11*xx12*xx13*xx14*xx15*

xx16*xx17*xx18*xx19*xx20*xx21*xx22*xx23*xx24*xx25*xx26*xx27*xx28*xx29*xx30*

xx31*xx32*xx33*xx34*xx35*xx36*xx37*xx38*xx39*xx40*xx41*xx42*xx43*xx44*xx45*

xx46*xx47*xx48*xx49*xx50*xx51*xx52*xx53*xx54*xx55*xx56*xx57*xx58*xx59*xx60*

xx61*xx62*xx63*xx64*xx65*xx66*xx67*xx68*xx69*xx70*xx71*xx72*xx73*xx74*xx75*

xx76*xx77*xx78*xx79*xx80*xx81*xx82*xx83*xx84*xx85

/ missing norow nocol nopercent

out=psm_miss; run;

proc print data=psm_miss; run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@Reeza @Astounding @Tommy1 thank you for your prompt responses!

So I am looking for all possible combinations of missing data.

I just ran a smaller example with only 5 of my variables and this is the output I got.

In the end, what I would like to have is this same table, but using all 85 variables. Please excuse my lack of clarity. I hope it makes more sense now.

@Tommy1 This is the first time I see that procedure. I see that it is similar to what I am looking for, but will it also show me the counts and proportions as shown in the table I just posted?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Yea it will show you the frequency and proportions.

The third example here provides a good example of what it will look like

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks so much! it worked

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Here's a way to get what the program is attempting.

At the end of the DATA step, combine your flags into a single variable:

all_flags = cats(of xx1-xx85);

Then run a PROC FREQ on the variable ALL_FLAGS. (With a single variable, you could just let PROC FREQ print its results.)

However ...

It's not at all clear that this is what you are intending. It's merely what your program would generate if it could work. So if this isn't the right result, you would have to post a smaller example of what you are hoping to achieve.

****************** EDITED:

Based on the sample table you posted, this approach should work just fine. It might be a little work to identify the values within ALL_FLAGS, but the idea is sound.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

What you may be looking for is using PROC MI to create a grid describing the data.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

As others have said, you can use PROC MI to display patterns of missing values

```
ods select MissPattern;
proc mi data=Sashelp.Heart nimpute=0
DISPLAYPATTERN=NOMEANS; /* this option requires SAS 9.4M5 */
var AgeAtStart Height Weight Diastolic
Systolic MRW Smoking Cholesterol;
run;
```

.You can also use various graphical techniques to visualize patterns of missing values. For 50 variables, I recommend the heat map, assuming there are not too many observations.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

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.