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

Dear All,

I'm pretty new to SAS and i'm having a confusion with one of my query. I have a data structure as mentioned below and need summarised output and i'm simply confused with which proc function this can be done and how.

I have below this table

Name - Prod

A1 - CC

A2 - CC

A3 - LN

A1 - CC

A3-ST

A1-CC

A2-LN

A3-CC

A1-LN

A1-CC

My output should be

Name   CC    LN     ST

A1        4        1      0

A2        1        1      0

A3        1        1      1

Pls anyone can help me with code...

Thanks  a lot...

Rgds, Anil

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Either Proc freq or tabulate would do. The syntax for freq is probably simpler:

proc freq data=yourdatasetname;

tables name*prod/ norow nocol nocum nopercent;

run;

View solution in original post

3 REPLIES 3
ballardw
Super User

Either Proc freq or tabulate would do. The syntax for freq is probably simpler:

proc freq data=yourdatasetname;

tables name*prod/ norow nocol nocum nopercent;

run;

aj34321
Quartz | Level 8

Shaks.. that's it.. just a single line of code and its done.. and i was breaking my head last 3 hours trying so many variations... Thanks a lot Ballard.. Now just one more small query in addition to it..

I also have one more column for LN & ST which mentions amount and i want to sum them for each name....

Thanks once again...

Rgds, Anil

Rick_SAS
SAS Super FREQ

Sounds like you want to include a WEIGHT statement:
proc freq ....;

WEIGHT amount;
tables ....;

run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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