BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bcoote
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

9 REPLIES 9
Shmuel
Garnet | Level 18

Can you demostrate in a table what do you mean?

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

PaigeMiller
Diamond | Level 26

Do you mean?

 

proc freq data=have;
    tables x*y;
run;
--
Paige Miller
bcoote
Fluorite | Level 6

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?

art297
Opal | Level 21

Are you looking for something like?:

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

Art, CEO, AnalystFinder.com

 

 

aespinarey
Obsidian | Level 7

Is there a way to have an statement similar to this one come up with only one table rather than multiple tables? kind of like a demographics table comparing 2 different population (i.e. Smokers and Non Smokers). 

art297
Opal | Level 21

Yes there is, but post your question in a new thread as this one is already closed. Plus, in the new thread you post, include some sample data (in the form of a datastep), as well as what you want the output to look like.

 

Art, CEO, AnalystFinder.com

 

bcoote
Fluorite | Level 6

Hello,

 

This table illustrates what I would like to display. 

 

Thank you for your assistance. 

ballardw
Super User

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.

 

heatherjae15
Obsidian | Level 7

How do I get 2 variables and 1 column of frequency (called number of subjects) into a table?  Right now, I have the variables ID and  site and I need number of patients without the frequency heading.  

 

So the table would be

       ID      Site     number of patients (given by freqency)?

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 59027 views
  • 4 likes
  • 7 in conversation