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

Hello,

I have a table:

Custnumindicxindicyindicz
11101
21011
31110
41110

I want to summarize the data to have this output

indicxindicyindicz
indicx321
indicy231
indicz112

What is the quickest way to do it ?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
GeoffDer
Calcite | Level 5

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;

View solution in original post

6 REPLIES 6
Astounding
PROC Star

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?

Reeza
Super User

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?

tlk
Quartz | Level 8 tlk
Quartz | Level 8

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!

Astounding
PROC Star

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.

GeoffDer
Calcite | Level 5

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;

Reeza
Super User

Nice and simple, love it Smiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 6 replies
  • 1987 views
  • 6 likes
  • 4 in conversation