Example data and the proc freq code you want to simulate.
Note: if you are using Proc Freq to compute anything other than counts the code in a single Data step is likely to be ugly at best and impossible at worst. Even just doing counts of something like : tables x*y is going to be somewhat ugly.
Are you asking:
It would be very helpful if you would add more details to your question before you post them. A rough idea is to show what you have, what you want and what you've tried so far.
@BrahmanandaRao wrote:
How to get proc freq output
Using datastep
If the extremely little effort you put into asking questions here is typical for the effort you put into work, then any interviewer will be well advised to not recommend you for hiring.
Please show us that this impression is wrong.
@BrahmanandaRao wrote:
Interviewer asked
It obviously took that (intended) insult to get you to write a complete sentence with some information content. Now answer our questions and provide details about your issue, so we can be of help.
@BrahmanandaRao wrote:
Interviewer asked
Next time, if there is one, then ask the interviewer for the specific Proc Freq code to emulate.
And if the result is supposed to be duplicated by a single Data step.
Take a look in the documentation at just how many options are available for the tables statement, especially the tests like Chi-squares or odds ratios. Then look up what is involved with calculating the pieces needed to do those.
Since a single Proc Freq call can have for practical purposes an unlimited number of tables statements requesting different output for each one with differing numbers of variables the actual content of the freq code really needs to be determined.
And the Plots options are right out unless you have delved into the not very often mentioned of the Data Step Graphic Interface.
I suspect the question was not about "data step" coding as much as awareness of the multiple options available in Proc Freq.
Even at the basic one way or two way table it's a decent question for an interview - the correct response is I would never do that manually, but if I had to for some reason then this how I would do it.
A one way or two table tests by group processing, control of output and retain calculations in a single step that should be relatively quick for a SAS programmer who understands data step processing.
I 100% agree that trying to replicate a tested process with manual complicated statistical calculations is a bad idea.
@BrahmanandaRao wrote:
same proc freq output
In data step
As before, I ask for further explanation and details, which this does not provide. Please put some time and effort into asking clear and understandable questions, with enough explanation and details so we know what you mean. Your extreme brevity is not a good way to ask questions.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.