I am looking for the following format
age_group | gender | race | Frequency | Percent | CumFrequency | CumPercent |
1 | female | white | ||||
1 | male | white | ||||
2 | female | white | ||||
2 | male | black | ||||
3 | female | asian | ||||
3 | male | black |
ods output onewayfreqs= test_owf
proc freq data=test ;
table gender race/missing;
by age_group;
run;
ods listing;
I get what I want but i was wondering if there is an easier way because when i do ods output , it always ends up outputting the results. i just want the output in different dataset rather than showing in results view
If your aim is to create an output dataset - try this:
proc freq data=test ;
table gender race/missing OUT=your_dataset;
by age_group;
run;
@fdsaaaa wrote:
If your aim is to create an output dataset - try this:
proc freq data=test ; table gender race/missing OUT=your_dataset; by age_group; run;
If the objective is to not have anything appear in the Results window, or ods destination, then add the NOPRINT option to the Proc Freq statement. However you can only get ONE output data set per TABLES statement. And to get both variables per record you need both gender and race in the same table.
proc freq data=test noprint; tables gender*race /missing OUT=your_dataset; by age_group; run;
Or have the AGE_GROUP on the tables statement instead of BY:
proc freq data=test noprint; tables age_group* gender*race /missing OUT=your_dataset; run;
Did you check the test_owf data set? If you check the log, you should see the table has been created and should hold the output.
The ODS OUTPUT command should generate output.
Here's some instructions and explanations on how to capture output that is shown.
https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods...
@monday89 wrote:
I am looking for the following format
age_group gender race Frequency Percent CumFrequency CumPercent 1 female white 1 male white 2 female white 2 male black 3 female asian 3 male black ods output onewayfreqs= test_owf
proc freq data=test ;
table gender race/missing;
by age_group;
run;
ods listing;
I get what I want but i was wondering if there is an easier way because when i do ods output , it always ends up outputting the results. i just want the output in different dataset rather than showing in results view
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.