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