I want to run a report that gives me all the categories for all columns with percentages in one go. Like a single report. My tables could have >100 categorical (character) value fields. Issue is that it is taking very long and does not have enough memory to run for all fields - any ideas how to handle it
Want a single output
ods select none; ods noresults; ods output OneWayFreqs=OneWayFreqs; proc freq data=sashelp.class ; table _all_/ list; run; ods select all; data temp; set OneWayFreqs(drop=Table ); value=coalescec(of _character_); keep value; run; data want; merge OneWayFreqs(keep=Table Frequency Percent) temp; run;
Suggest: Provide a bit better description of your data. You can do that with Proc Freq and NLEVELS to report on the number of levels of each variable. Example:
ods select nlevels; proc freq data=sashelp.class nlevels; run;
The ODS select means that only the Nlevels table is generated which should not run out of memory but will give us an idea just how much stuff you are dealing with.
"Blank" is not a SAS value you will see. Depending on which procedure/approach you are dealing with you can use the MISSING option to get a count.
You can run into memory issues when generated large tables because the table with all the border information and such are stored in memory before writing out the results. If you have the default HTML destination and are sending the data to another ods destination that can seriously increase the memory needed. So you might have better results by closing the HTML destination and writing to only one destination like ODS RTF of PDF.
One basic syntax would look like:
proc tabulate data=yourSetNameHere; class _character_/missing; table _character_, n pctn; run;
but missing values will be at the top of each as the default order for character values is alphabetic and blanks come before any other printable character.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.