## Proc Tabulate : creating a row of zeros for nonexistent variable

Solved
Occasional Contributor
Posts: 8

# Proc Tabulate : creating a row of zeros for nonexistent variable

Hello, this is my code and it produces the graph below.

Proc tabulate data=sample;
class term type;
keylabel n=" ";
format type \$type. term \$terms.;
run;

 Headcount Fall 2015 Spring 2016 Summer 2016 2015 Adult Degree 120 130 114 118 RN 45 32 34 41 Traditional Undergraduate 200 181 192 212 Total Undergraduate - Campus 365 343 340 371

My data is listed as:

Data Fall2015;
input Term \$ Cr_Att Type \$;
datalines;
15FALL   3   RN
15FALL   12   TU

;

run;

I was wondering if there is a way to create a row category of all zeros for a variable (Type ="GS") that does not in my dataset.

Below is an example

 Headcount Fall 2015 Spring 2016 Summer 2016 2015 Adult Degree 120 130 114 118 Grad students 0 0 0 0 RN 45 32 34 41 Traditional Undergraduate 200 181 192 212 Total Undergraduate - Campus 365 343 340 371

Accepted Solutions
Solution
‎02-14-2017 01:44 PM
Posts: 1,318

## Re: Proc Tabulate : creating a row of zeros for nonexistent variable

``````proc format;
value \$gndr
'F' = 'Female'
'M' = 'Male'
'O' = 'Other';
run;

proc tabulate data=sashelp.class;
table sex/ printmiss misstext='0';
format sex \$gndr.;
run;``````

All Replies
Super User
Posts: 13,941

## Re: Proc Tabulate : creating a row of zeros for nonexistent variable

Create a format to associate with the class variable with all of the values which it looks like you may have, use the PRELOADFMT option on class statement.

This may do it:

```Proc tabulate data=sample;
class term ;
keylabel n=" ";
format type \$type. term \$terms.;
run;```
Solution
‎02-14-2017 01:44 PM
Posts: 1,318

## Re: Proc Tabulate : creating a row of zeros for nonexistent variable

``````proc format;
value \$gndr
'F' = 'Female'
'M' = 'Male'
'O' = 'Other';
run;

proc tabulate data=sashelp.class;
table sex/ printmiss misstext='0';
format sex \$gndr.;
run;``````
Occasional Contributor
Posts: 8

## Re: Proc Tabulate : creating a row of zeros for nonexistent variable

[ Edited ]

Proc tabulate data=sample;