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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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