Programming the statistical procedures from SAS

Summary table

Accepted Solution Solved
Reply
Contributor tlk
Contributor
Posts: 49
Accepted Solution

Summary table

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!


Accepted Solutions
Solution
‎02-12-2015 04:27 PM
New Contributor
Posts: 4

Re: Summary table

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


All Replies
Respected Advisor
Posts: 4,756

Re: Summary table

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?

Grand Advisor
Posts: 16,865

Re: Summary table

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?

Contributor tlk
Contributor
Posts: 49

Re: Summary table

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!

Respected Advisor
Posts: 4,756

Re: Summary table

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.

Solution
‎02-12-2015 04:27 PM
New Contributor
Posts: 4

Re: Summary table

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;

Grand Advisor
Posts: 16,865

Re: Summary table

Nice and simple, love it Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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