BookmarkSubscribeRSS Feed
Quartz | Level 8

I have 10 variables with count data, I want to create a matrix something like this.




Each variable has unequal frequency distribution. I used PROC FREQ but it gives output for each variable but not matrix. Can someone help me with this?



Opal | Level 21

I think you need to revisit your plan.  Couldn't multiple values of X have the same COUNT?




OK, I take it back.  I think I see what you are after.  But I don't see a one-step process to get it.  Is a multi-step process permitted?




Taking it back again ... if your data is in the right form, you could use:


proc tabulate data=have;

class count;

var x y z;

tables count, n * (x y z);



Many features are available to customize the table.

Quartz | Level 8

The first variable in the picture is supposed to me "Value" instead of "Count", my mistake.

The values under X are count frequency, so each value is unique. It is read as "With value 1 there are 10 X, 12 Y and 25 Y, With value 2 there are 10 X, 12 Y and 25 on"

Opal | Level 21

Yes, it took me a minute to realize that you had the frequencies already calculated.


It would help if you could show 3 or 4 observations from the incoming data. 


You can probably use the program I already posted, using VALUE instead of COUNT.


Quartz | Level 8

I didn't include the names of the varibales here, so imagine each separation is a variable with some name.

Super User

Instrunctions at: show how to create datastep code that you can paste here to show what your data (example or dummy) actually looks like. Then we can actually run the code to have a dataset with the  same characteristics and test code.

Pictures, especially without variable names and such aren't extremely helpful.


And is that example data supposed to generate the desired output shown in the first post? If not, what is the desired output for the shown data?


I suspect something like this may be what you are looking for:

proc tabulate data= have;
   class value;
   var x y z;
   table value,
         (x y z)*n /* or sum your example input and output data don't really match*/;
Quartz | Level 8

Sorry, I can't give the variable names. The second picture each column can be represented as X, Y, Z etc. 

The first picture is the final output I want to have.




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 3 in conversation