BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Q1983
Lapis Lazuli | Level 10

 

proc freq data=mytable; tables PROD_KEY_2/missing; run;

produces this in the Results section

PROD_KEY_2

PROD_KEY_2

Frequency

Percent

Cumulative Frequency

Cumulative Percent

3112

1

0.14

1

0.14

3501

3

0.42

4

0.56

4101

2

0.28

6

0.83

5112

315

43.75

321

44.58

5122

337

46.81

658

91.39

5300

7

0.97

665

92.36

5400

55

7.64

720

100.00

When I use proc print mytable it produces the detail dataset.  I want to reproduce the above table output for ODS output

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

To output to ODS either wrap the PROC FREQ in ODS statements 

OR

Capture the table using an OUTPUT statement and then PROC PRINT on that. 

 

See the answer here, which is what you're trying to do. 

https://communities.sas.com/t5/SAS-Procedures/Count-by-Variable-Groups/m-p/493096#M72254

 

And in general, you can always use the ODS tables.

https://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html

 


@Q1983 wrote:

 

proc freq data=mytable; tables PROD_KEY_2/missing; run;

produces this in the Results section

PROD_KEY_2

PROD_KEY_2

Frequency

Percent

Cumulative Frequency

Cumulative Percent

3112

1

0.14

1

0.14

3501

3

0.42

4

0.56

4101

2

0.28

6

0.83

5112

315

43.75

321

44.58

5122

337

46.81

658

91.39

5300

7

0.97

665

92.36

5400

55

7.64

720

100.00

When I use proc print mytable it produces the detail dataset.  I want to reproduce the above table output for ODS output


 

View solution in original post

1 REPLY 1
Reeza
Super User

To output to ODS either wrap the PROC FREQ in ODS statements 

OR

Capture the table using an OUTPUT statement and then PROC PRINT on that. 

 

See the answer here, which is what you're trying to do. 

https://communities.sas.com/t5/SAS-Procedures/Count-by-Variable-Groups/m-p/493096#M72254

 

And in general, you can always use the ODS tables.

https://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html

 


@Q1983 wrote:

 

proc freq data=mytable; tables PROD_KEY_2/missing; run;

produces this in the Results section

PROD_KEY_2

PROD_KEY_2

Frequency

Percent

Cumulative Frequency

Cumulative Percent

3112

1

0.14

1

0.14

3501

3

0.42

4

0.56

4101

2

0.28

6

0.83

5112

315

43.75

321

44.58

5122

337

46.81

658

91.39

5300

7

0.97

665

92.36

5400

55

7.64

720

100.00

When I use proc print mytable it produces the detail dataset.  I want to reproduce the above table output for ODS output


 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2481 views
  • 1 like
  • 2 in conversation