Hi,
I am associating a user defined format with a variable and generating a freq report. I want to see all values of proc format in the report, even though they may not be in the dataset. Below is an example.
proc format;
value test
.='Missing'
low-<0='<0'
1-5='1-5'
6-10='6-10'
11-15='11-15'
16-high='15+'
;
run;
data test;
infile datalines;
input a;
datalines;
.
-1
5
7
18
;
run;
proc freq data=test;
tables a/list missing sparse;
format a test.;
run;
The resulting report does not show the 11-15 range since it is not in the dataset. I want to show missing for 11-15.
Help appreciated.
PRELOOADFMT is the option your looking for, in combination with PROC TABULATE.
Proc tabulate data = have;
Class a / preloadfmt missing;
Format a test.;
Table a;
Run;
Tabulate has several percentage calculators available. You might try
Proc tabulate data = have;
Class a / preloadfmt missing;
Format a test.;
Table a,
n pctn;
Run;
Try adding the PRINTMISS option after the TABLE statement.
See the example in the docs:
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.