BookmarkSubscribeRSS Feed
srikanthyadav44
Quartz | Level 8

dear all

 

my dataset is a panel data of nearly 2000 companies for 18 years. for every year, each company observation is repeated for multiple times. 

i have to count the frequency of each company for every year in the data set and  to prepare a separate frequency table.

 

the example of my data set is as follows

Company Nameyear
3P Land Holdings Ltd.2001
3P Land Holdings Ltd.2001
3P Land Holdings Ltd.2001
3P Land Holdings Ltd.2001
3P Land Holdings Ltd.2001
52 Weeks Entertainment Ltd.2001
52 Weeks Entertainment Ltd.2001
52 Weeks Entertainment Ltd.2001
7Seas Entertainment Ltd.2001
7Seas Entertainment Ltd.2001
7Seas Entertainment Ltd.2001
3P Land Holdings Ltd.2002
3P Land Holdings Ltd.2002
3P Land Holdings Ltd.2002
3P Land Holdings Ltd.2002
3P Land Holdings Ltd.2002
3P Land Holdings Ltd.2002
A B C India Ltd.2002
A B C India Ltd.2002
A B C India Ltd.2002
A B C India Ltd.2002
A B C India Ltd.2002
A B C India Ltd.2002
A B C India Ltd.2002

 

the required frequency table is 

company name yearfrequency
3P Land Holdings Ltd.20015
52 Weeks Entertainment Ltd.20013
A B C India Ltd.20027

 

please suggest me a SAS code to prepare the  frequency table as given above.

 

thanks in advance. 

2 REPLIES 2
Watts
SAS Employee
proc freq data=have;
    tables Company * Year / list nocum nopct;
run;
ballardw
Super User

Another way:

Proc summary data=have nway;
   class company year ;
   output out=work.summary (drop=_type_);
run;

The output set work.summary will have a variable named _freq_ with the count of combinations of company and year.

The NWAY is have the output only include records with both company and year. Summary can create a number of other combinations of the class variables. The _type_ variable is an indicator of which combination of class variables each record reflects.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 818 views
  • 2 likes
  • 3 in conversation