Hello,
I am new in SAS and having hard time figuring out freq and sort procedures. Please assist me with the following questions:
Which industry code has the most records in file Q_COMP_SHORT10_18?
Which State has the most records in file Q_COMP_SHORT10_18?
Find the Top100 records with the highest average inventory turnover?
I am not sure if the industry code is SIC or TIC ?
Thank you
You can run a PROC FREQ and specify that the data is ordered by frequency so that you can easily find the top values.
I would assume SIC is Standard Industry Classification but that's not something someone external can answer with any certainty because we don't know about your data.
Here's an example on how you'd answer which is the more frequent SEX in the data set
proc freq data=sashelp.class order=freq;
table sex;
run;
@FEFE90 wrote:
Hello,
I am new in SAS and having hard time figuring out freq and sort procedures. Please assist me with the following questions:
Which industry code has the most records in file Q_COMP_SHORT10_18?
Which State has the most records in file Q_COMP_SHORT10_18?
Find the Top100 records with the highest average inventory turnover?
I am not sure if the industry code is SIC or TIC ?
Thank you
You can run a PROC FREQ and specify that the data is ordered by frequency so that you can easily find the top values.
I would assume SIC is Standard Industry Classification but that's not something someone external can answer with any certainty because we don't know about your data.
Here's an example on how you'd answer which is the more frequent SEX in the data set
proc freq data=sashelp.class order=freq;
table sex;
run;
@FEFE90 wrote:
Hello,
I am new in SAS and having hard time figuring out freq and sort procedures. Please assist me with the following questions:
Which industry code has the most records in file Q_COMP_SHORT10_18?
Which State has the most records in file Q_COMP_SHORT10_18?
Find the Top100 records with the highest average inventory turnover?
I am not sure if the industry code is SIC or TIC ?
Thank you
Thank you for your response. so we don't have to sort the data before using proc freq ?
Bests
Try it! You'll see.
@FEFE90 wrote:
Thank you for your response. so we don't have to sort the data before using proc freq ?
Bests
It depends on the PROC FREQ code. You're only required to sort your data if you're using a BY statement and then the BY statement will be the same between the SORT and FREQ procedure. Given your current question, there's no need for BY group analysis and no need to pre-sort your data.
The FREQ option will ensure the output is sorted to make it easier to answer your questions. And, as @PGStats mentioned, the best thing about programming is you can always answer these questions yourself by running various options and seeing what happens.
Can you please check the last question: Finding the top100 with the highest average inventory turnover? I did this but it gave me wrong answer?
You sort TOP100, but in the next step you use Q4.
Thank you I changed it to TOP100, but still the answer is wrong.
Define "wrong". The word as such tells us exactly NOTHING.
Supply example data so we can run your code against it, and tell us where the result differs from your expectations.
Use a data step with datalines to post example data, see my footnotes.
I can check the final answer if it's correct or not. But it is not shown the correct code. I will see it thank you
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.