Hello,
I have a table:
Custnum | indicx | indicy | indicz |
---|---|---|---|
11 | 1 | 0 | 1 |
21 | 0 | 1 | 1 |
31 | 1 | 1 | 0 |
41 | 1 | 1 | 0 |
I want to summarize the data to have this output
indicx | indicy | indicz | |
---|---|---|---|
indicx | 3 | 2 | 1 |
indicy | 2 | 3 | 1 |
indicz | 1 | 1 | 2 |
What is the quickest way to do it ?
Thank you!
Try this
data test;
input id v1-v3;
cards;
11 1 0 1
21 0 1 1
31 1 1 0
41 1 1 0
;
ods output sscp=coocs;
proc corr sscp;
var v1-v3;
run;
proc print data=coocs;
run;
Clearly, the quickest way would be to hire a consultant.
But if you want to program this yourself, you have to answer a few questions first.
What is your output? Is it a report, or is it a data set?
Is there any flexibility in the requirements? For example, there are going to be 6 numbers, and 3 repeats in your results. Do you need all 9 numbers in the output?
Do you want a program that is limited to these 3 variables, or do you need something that might expand to more variables?
Information is duplicated in this table so it isn't a really efficient way to store data unless it's for reporting.
What are you planning to use it for?
In my real data I have 10 000 custnum (10 000 obs) and have 10 indicators. This table tell us which services each customers have use last year, I can summarize each indicators independantly(easy part). I would like to see in a report which combination of services were used.
I'll continue to work on this, maybe I should make up a class variable by combining my indicators and have proc summary.
I thought there was a Stat proc that could do this.
Thanks!
For three variables, it's easy to count all the combinations. PROC FREQ is the simplest counting tool:
proc freq data=have;
tables indicx * indicy * indicz / missing list;
run;
See if this does what you need for three variables.
When you have larger numbers of variables, such as 10, this may not fit onto the page. You could increase the width of each line although there are limits and you may need to read the results on a browser not a printer:
options linesize=255;
... then run PROC FREQ.
Good luck.
Try this
data test;
input id v1-v3;
cards;
11 1 0 1
21 0 1 1
31 1 1 0
41 1 1 0
;
ods output sscp=coocs;
proc corr sscp;
var v1-v3;
run;
proc print data=coocs;
run;
Nice and simple, love it
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 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.