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
@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.
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.
@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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: