SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
sasmaverick
Obsidian | Level 7

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.

 

5 REPLIES 5
Reeza
Super User

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;
sasmaverick
Obsidian | Level 7
This doesn't give me percentages.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
ballardw
Super User

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;

sasmaverick
Obsidian | Level 7
Are you sure this is working. I still don't see 11-15 range in the report.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Reeza
Super User

Try adding the PRINTMISS option after the TABLE statement. 

 

See the example in the docs:

http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p1f1t9bipbeqy5n1vowhz...

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2508 views
  • 0 likes
  • 3 in conversation