Turn on suggestions

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

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- frequency table when you have many variables

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 03-03-2021 08:32 PM
(358 views)

Hello all,

Appreciate you helping me find a way to get two by two frequency table apply proc freq. I have many categorical variables, it is time consuming to enter all variables two by two.

1 ACCEPTED SOLUTION

Accepted Solutions

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

@fatemeh wrote:

Hello all,

Appreciate you helping me find a way to get two by two frequency table apply proc freq. I have many categorical variables, it is time consuming to enter all variables two by two.

The proc freq tables statement allows use of parentheses to create "groups" of variables that get treated similarly.

So

tables (a b c d) *(p d q r); is short hand for all of the pairs of the variables in the first parentheses and all in the second:

a*p a*d a*q a*r b*p b*c b*q b*r etc.

You cal also use variable lists:

tables (a1-a10 ) *(v1-v15). If you have 10 variables that start with a. So that would do a1*v1 a1*v2 ... a1*v15 a2*v1 ... a2*v15 ... a10*v1 .. a10*v15.

you could cross all of the variables using the special list _all_.

Tables _all_* _all_;

but don't expect to get the output quickly with a large data set with lots of variables. 50 variables in the data set means 50*50 tables, or 2500.

1 REPLY 1

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

@fatemeh wrote:

Hello all,

Appreciate you helping me find a way to get two by two frequency table apply proc freq. I have many categorical variables, it is time consuming to enter all variables two by two.

The proc freq tables statement allows use of parentheses to create "groups" of variables that get treated similarly.

So

tables (a b c d) *(p d q r); is short hand for all of the pairs of the variables in the first parentheses and all in the second:

a*p a*d a*q a*r b*p b*c b*q b*r etc.

You cal also use variable lists:

tables (a1-a10 ) *(v1-v15). If you have 10 variables that start with a. So that would do a1*v1 a1*v2 ... a1*v15 a2*v1 ... a2*v15 ... a10*v1 .. a10*v15.

you could cross all of the variables using the special list _all_.

Tables _all_* _all_;

but don't expect to get the output quickly with a large data set with lots of variables. 50 variables in the data set means 50*50 tables, or 2500.

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.