BookmarkSubscribeRSS Feed
Sujithpeta
Quartz | Level 8

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

 

Untitled.png

 

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?

 

Thanks

6 REPLIES 6
Astounding
PROC Star

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);

run;

 

Many features are available to customize the table.

Sujithpeta
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 Y...so on"

Astounding
PROC Star

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.

 

Sujithpeta
Quartz | Level 8

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


Untitled.png
ballardw
Super User

Instrunctions at: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... 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*/;
end;
Sujithpeta
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.

Thanks

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!

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.

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
  • 6 replies
  • 2296 views
  • 0 likes
  • 3 in conversation