Hello,
I have a dataset with several columns: var_name, frequency, %, code, source, year.
I want to suppress frequency and % if frequency < 6.
Can you please help me coding for this?
Thank you,
Yoko
Do you mean you want PROC FREQ to calculate everything, and then not display results where sample size < 6? Or do you mean the sample size is already calculated in your data set before PROC FREQ is run?
Show us a portion of the actual data.
Hello,
My title may be misleading. I run proc freq and create a dataset based on it
My data looks like this:
There are only 1 level for var_name (var1), source (book1), and year (2022) each.
To be true to the original data, I added an empty cell to 'code' as well.
The frequency and % are numeric variables.
I want to replace '1' with, say, '*'.
Thank you,
Yoko
Well, this new explanation doesn't really help, nor is it clear what results you want from this data set or how this data set relates to your original problem description. Showing us data where the variables have only 1 value also isn't a helpful thing to do.
Please give us a complete and clear explanation. Please show us a larger and more realistic portion of your data (do not show us screen captures, we need to see your data as SAS data step code — instructions), AND the desired output.
Example data, or use a SAS supplied data set such as SASHELP.CLASS, and show the expected output. There are several ways to interpret "suppress small sample" and it is not at all clear which you may mean.
It seems like there are two ways to interpret your question.
1. Do the frequency analysis on the full set of data, but only report the larger groups for which the count exceeds 6 obs.
2. Exclude the groups that have 6 or fewer obs. Perform the frequency analysis on the remaining data.
Both methods are shown below:
/* The Type="Hybrid" class has less than 6 obs */
proc freq data=sashelp.cars;
table Type / out=FreqOut;
run;
/* First interpretation: don't report that group.
Note the percentage do not add to 100. */
proc print data=FreqOut;
where Count > 6;
run;
/* Second interpretation: delete small groups and
rerun the analysis. Now the percentages of the
remaining groups sum to 100. */
proc freq data=FreqOut;
where Count > 6;
table Type;
weight Count;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.