BookmarkSubscribeRSS Feed
gstover
Fluorite | Level 6

Is there a way to add a column variable in proc tabulate that is not on the raw data?

 

I have a gender categories of Female, Male and Unknown.  I would like to display the Unknown column and it is not on my raw data.

Is there a way to do this?

2 REPLIES 2
Reeza
Super User
See page 4 / Example 3 here
https://www.lexjansen.com/nesug/nesug11/cc/cc29.pdf

PRELOADFMT or COMPLETETYPES are the terms that you can google with PROC TABULATE.
ballardw
Super User

If your  "unknown" means that the variable that holds gender has the value missing then one way is to do three things assuming this is used as a Class variable:

1) on the Class statement add the MISSING option so missing is included in the report. This would look like:

Class gender / missing;

2) create a format that displays missing values as "Unknown"

3) associate the format with the variable with a format statement.

Example

proc format;
value $missgender
' ' = 'Unknown'
;
run;

data example;
   input gender $ varx;
datalines;
Female  123
Male    456
.       111
;

proc tabulate data=example;
   class gender/missing;
   format gender $missgender.;
   var varx;
   table gender,
         varx*mean
   ;
run;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 269 views
  • 0 likes
  • 3 in conversation