DATA Step, Macro, Functions and more

PROC FREQ - print only count and output to another dataset

Accepted Solution Solved
Reply
Contributor
Posts: 53
Accepted Solution

PROC FREQ - print only count and output to another dataset

Hi all,

I am trying to use PROC FREQ.

1. I don't want any other information except count (tried using NOROW NOCOL NOPERCENT as well as /LIST).

.

2 In the same step, I also want to output the data to another dataset (output).

proc freq data = abc NOPRINT;

tables xyz/ NOROW NOCOL NOPERCENT out = output ;

RUN;

tables xyz/ out = output1 (drop = percent) / LIST;

I know I am doing some syntax error. Please help.

Thanks,

Archana


Accepted Solutions
Solution
‎08-17-2015 11:22 AM
Valued Guide
Posts: 765

Re: PROC FREQ - print only count and output to another dataset

Hi.  Since you know what you want in data set OUTPUT1, try using KEEP ...

tables xyz/ out=output1 (keep=xyz count);

Also, you're only allowed one slash (/) in the TABLES statement.  You can list multiple options after that slash.

Here's an  example with a printed table of just counts plus an output data set with just counts ...

proc freq data=sashelp.class;

table age / out=counts (keep=age count) nopercent nocum;

run;

View solution in original post


All Replies
Super User
Super User
Posts: 7,392

Re: PROC FREQ - print only count and output to another dataset

Not too familiar with freq, you could do means though:

proc means data=abc;

     var xyz;

     output out=out_dataset n=n;

run;

Also remember, you can put:

ods trace one;

Before your freq and see what objects are created, then do;

ods output <object>=<dataset>;

Solution
‎08-17-2015 11:22 AM
Valued Guide
Posts: 765

Re: PROC FREQ - print only count and output to another dataset

Hi.  Since you know what you want in data set OUTPUT1, try using KEEP ...

tables xyz/ out=output1 (keep=xyz count);

Also, you're only allowed one slash (/) in the TABLES statement.  You can list multiple options after that slash.

Here's an  example with a printed table of just counts plus an output data set with just counts ...

proc freq data=sashelp.class;

table age / out=counts (keep=age count) nopercent nocum;

run;

Contributor
Posts: 53

Re: PROC FREQ - print only count and output to another dataset

Thanks a lot MikeZdeb, you answered perfectly Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 548 views
  • 0 likes
  • 3 in conversation