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
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
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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.