Created
December 15, 2021 01:55
-
-
Save statgeek/c91ec43ce4f0ef24c440c95465611123 to your computer and use it in GitHub Desktop.
Create an Other Category automatically within PROC FREQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This is an example of how to create an Other category for everything except the top 3*/ | |
*not ideal, other becomes first format - will look into how to make it last value; | |
*get counts; | |
proc freq data=sashelp.class order = freq; | |
table age / out=counts; | |
run; | |
*create format; | |
data counts_fmt; | |
set counts (OBS=3) end=eof; | |
*length label $10.; | |
fmtname = 'Age_fmt'; | |
start = age; | |
label = age; | |
output; | |
if eof then do; | |
hlo = 'O'; | |
label = 'Other'; | |
output; | |
end; | |
run; | |
proc format cntlin=counts_fmt; | |
run; | |
*test applied format; | |
proc freq data=sashelp.class; | |
table age; | |
format age age_fmt.; | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment