BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Yoko
Obsidian | Level 7

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Create a custom format and apply that to the output data. PROC TABULATE is slightly easier in this regard.

proc format;
value mask_fmt
low < 6 = "<6"
other = [comma12.];
run;

Then apply that within PROC FORMAT.

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

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. 

 

 

--
Paige Miller
Yoko
Obsidian | Level 7

Hello, 

My title may be misleading.  I run proc freq and create a dataset based on it

My data looks like this: 

Yoko_0-1647347659506.png

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

 

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Reeza
Super User
Create a custom format and apply that to the output data. PROC TABULATE is slightly easier in this regard.

proc format;
value mask_fmt
low < 6 = "<6"
other = [comma12.];
run;

Then apply that within PROC FORMAT.
ballardw
Super User

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.

Rick_SAS
SAS Super FREQ

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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1080 views
  • 2 likes
  • 5 in conversation