BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
How to get proc freq output
Using datastep
12 REPLIES 12
PaigeMiller
Diamond | Level 26

Hello @BrahmanandaRao 

 

Could you explain further? Provide details? Thanks!

--
Paige Miller
ballardw
Super User

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.

 

 

Reeza
Super User

Are you asking:

  1. How to save the output from PROC FREQ to a dataset
  2. How to get the same output you would from PROC FREQ using a data step instead
  3. Something else?

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

 

BrahmanandaRao
Lapis Lazuli | Level 10
same proc freq output
In data step
Reeza
Super User
Why?
BrahmanandaRao
Lapis Lazuli | Level 10
Interviewer asked
Kurt_Bremser
Super User

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

 

BrahmanandaRao
Lapis Lazuli | Level 10
Hi KurtBremser
If you don't want to give answer please ignore me here after please don't make insult
of course you are expert in coding but i am beginner
Kurt_Bremser
Super User

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.

ballardw
Super User

@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.

 

Reeza
Super User

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. 

PaigeMiller
Diamond | Level 26

@BrahmanandaRao wrote:
same proc freq output
In data step

@BrahmanandaRao 

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.

--
Paige Miller

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
  • 12 replies
  • 1286 views
  • 3 likes
  • 5 in conversation