Hello,
My data is as follow:
I intend to use proc means in order to calculate number of variables that relate to this table. If I want to calculate the Number of observations that I use function N in proc means. Which function should I use to calculate the number of firms?
Thanks for any help
Yael
Proc Means will not do what you are requesting in a single pass with the data you have.
Options would be to modify the data a bit to include a variable that is assigned a value that could be processed with either N or sum. For tables such as you show I would switch from summary to a report procedure:
data want; set have; by firm; FirmCount = first.firm; run; proc tabulate data= have ; class ff status; var Firmcount; table ff, status=''*n='' /style=[Pretext='Observations']; table ff, status=''*FirmCount=''*sum=''*f=best5. /style=[Pretext='Firams']; run;
Other options would be summarize the data twice once with firm as class variable (or use Proc Freq) and then summarize the result again.
In the future to get better responses post input, and if possible output, data in the form of a data step so that we can duplicate what you have. Not many people are going to type in your data to test code. An existing SAS data set can be turned into data step using: Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
Proc Means will not do what you are requesting in a single pass with the data you have.
Options would be to modify the data a bit to include a variable that is assigned a value that could be processed with either N or sum. For tables such as you show I would switch from summary to a report procedure:
data want; set have; by firm; FirmCount = first.firm; run; proc tabulate data= have ; class ff status; var Firmcount; table ff, status=''*n='' /style=[Pretext='Observations']; table ff, status=''*FirmCount=''*sum=''*f=best5. /style=[Pretext='Firams']; run;
Other options would be summarize the data twice once with firm as class variable (or use Proc Freq) and then summarize the result again.
In the future to get better responses post input, and if possible output, data in the form of a data step so that we can duplicate what you have. Not many people are going to type in your data to test code. An existing SAS data set can be turned into data step using: Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
I accept your remark, thanks a lot!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.