DATA Step, Macro, Functions and more

Multiple Variables in PROC FREQ

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Multiple Variables in PROC FREQ

Hello,

 

Is there a way to create a table displaying the frequencies of multiple variables compared to one variable using PROC FREQ? I'm using SAS 9.4. 

 

Best,

Brittany Coote


Accepted Solutions
Solution
‎04-06-2018 08:59 PM
Super User
Posts: 13,084

Re: Multiple Variables in PROC FREQ

The following code uses a data set you should have available. It does something similar to what you show but with out example input data it isn't obvious whether we need to sum something or are using counts. Run this and see if the results are at all like what you want.

proc tabulate data=sashelp.cars;
   class make ;
   class type;
   class origin;
  tables type origin,
         (all='All makes' make)*( colpctn n)
         ;
run;

There are options and things that can change things like row or column headings, formats of values shown. ODS style choices or overrides in the code can remove cell boundaries, change background/foreground colors, fonts and lots of stuff.

 

View solution in original post


All Replies
Trusted Advisor
Posts: 1,828

Re: Multiple Variables in PROC FREQ

Can you demostrate in a table what do you mean?

Please post a sample data and the frequency table you want to achive.

Respected Advisor
Posts: 2,662

Re: Multiple Variables in PROC FREQ

Do you mean?

 

proc freq data=have;
    tables x*y;
run;
--
Paige Miller
New Contributor
Posts: 4

Re: Multiple Variables in PROC FREQ

Posted in reply to PaigeMiller

That is the format I am using, but I am trying to avoid having to do it for multiple variables. Is there a way to just compare multiple variables to one variable via frequencies?

PROC Star
Posts: 8,117

Re: Multiple Variables in PROC FREQ

Are you looking for something like?:

proc freq data=sashelp.class;
  tables sex*(age height weight);
run;

Art, CEO, AnalystFinder.com

 

 

New Contributor
Posts: 4

Re: Multiple Variables in PROC FREQ

Hello,

 

This table illustrates what I would like to display. 

 

Thank you for your assistance. 

Solution
‎04-06-2018 08:59 PM
Super User
Posts: 13,084

Re: Multiple Variables in PROC FREQ

The following code uses a data set you should have available. It does something similar to what you show but with out example input data it isn't obvious whether we need to sum something or are using counts. Run this and see if the results are at all like what you want.

proc tabulate data=sashelp.cars;
   class make ;
   class type;
   class origin;
  tables type origin,
         (all='All makes' make)*( colpctn n)
         ;
run;

There are options and things that can change things like row or column headings, formats of values shown. ODS style choices or overrides in the code can remove cell boundaries, change background/foreground colors, fonts and lots of stuff.

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 136 views
  • 0 likes
  • 5 in conversation