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

Showing results for

- Home
- /
- Programming
- /
- Programming
- /
- Re: Cross table

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 09-17-2020 07:54 AM
(797 views)

Dear all,

I would like to able to produce a cross table with 8 independent categorical variables the same way PROC CORR tabulates the correlation coefficients. I would need to know the frequency of each variable in relation to the other independent variable. I have tried PROC FREQ with the table feature which does part of what I would like but I would love to combine all that information into 1 table.

Thank you,

Pieter

1 ACCEPTED SOLUTION

Accepted Solutions

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

@paldejong wrote:

Dear all,

I would like to able to produce a cross table with 8 independent categorical variables the same way PROC CORR tabulates the correlation coefficients. I would need to know the frequency of each variable in relation to the other independent variable. I have tried PROC FREQ with the table feature which does part of what I would like but I would love to combine all that information into 1 table.

Thank you,

Pieter

"Each variable" or "each value of each variable"?

I don't know if this gives you a start or not but is at least quick and easy to test.

proc tabulate data=sashelp.class; class sex age; tables sex age, sex age /misstext=' ' ; run;

Any variable you place on the Class statement in tabulate will be treated as "categorical". The table statement places each variable in both a row and column. The misstext suppresses the many . you will get for missing values when any variable crosses with itself. There will be a warning in the log for each variable crossed with itself. No statistic is requested so you will N, or count.

Caution: Tabulate will by default remove records with any missing values for any class variables. If you don't want that then you would add the option \missing to the Class statement, which will then treat missing as a level of the variable.

3 REPLIES 3

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

It doesn't make sense to say you want a table involving categorical variables similar to PROC CORR, because PROC CORR works on continuous variables. The is no such table of categorical variables analogous to what PROC CORR produces.

So, you need to refine or re-think your question.

Better yet, show us an example with (let's say) three categorical variables, show us what you want.

--

Paige Miller

Paige Miller

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

@paldejong wrote:

Dear all,

I would like to able to produce a cross table with 8 independent categorical variables the same way PROC CORR tabulates the correlation coefficients. I would need to know the frequency of each variable in relation to the other independent variable. I have tried PROC FREQ with the table feature which does part of what I would like but I would love to combine all that information into 1 table.

Thank you,

Pieter

"Each variable" or "each value of each variable"?

I don't know if this gives you a start or not but is at least quick and easy to test.

proc tabulate data=sashelp.class; class sex age; tables sex age, sex age /misstext=' ' ; run;

Any variable you place on the Class statement in tabulate will be treated as "categorical". The table statement places each variable in both a row and column. The misstext suppresses the many . you will get for missing values when any variable crosses with itself. There will be a warning in the log for each variable crossed with itself. No statistic is requested so you will N, or count.

Caution: Tabulate will by default remove records with any missing values for any class variables. If you don't want that then you would add the option \missing to the Class statement, which will then treat missing as a level of the variable.

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

That is exactly what I needed.

Thank you!

Pieter

Thank you!

Pieter

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.