BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Bootler
Fluorite | Level 6

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


Proc tabulate data=sample;
class term type;
table (Type=" ") (all="Total Undergraduate - Campus"),(term="Headcount")/misstext = "0";
keylabel n=" ";
format type $type. term $terms.;
run;

 

 Headcount
Fall 2015Spring 2016Summer 20162015
Adult Degree120130114118
RN45323441
Traditional Undergraduate200181192212
Total Undergraduate - Campus365343340371

 

    
    
    
    

 

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 2015Spring 2016Summer 20162015
Adult Degree120130114118
Grad students0000
RN45323441
Traditional Undergraduate200181192212
Total Undergraduate - Campus365343340371
1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee
proc format;
value $gndr
'F' = 'Female'
'M' = 'Male'
'O' = 'Other';
run;

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

View solution in original post

3 REPLIES 3
ballardw
Super User

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 ;
   class type/preloadfmt order=data  ;
   table (Type=" ") (all="Total Undergraduate - Campus"),(term="Headcount")/ printmiss misstext = "0";
   keylabel n=" ";
   format type $type. term $terms.;
run;
FriedEgg
SAS Employee
proc format;
value $gndr
'F' = 'Female'
'M' = 'Male'
'O' = 'Other';
run;

proc tabulate data=sashelp.class;
class sex / preloadfmt;
table sex/ printmiss misstext='0';
format sex $gndr.;
run;
Bootler
Fluorite | Level 6

Thanks I already had a format in place, so all i did was add the preloadfmt and printmiss options.

 

Proc tabulate data=sample;
class term type/preloadfmt;
table (Type=" ") (all="Total Undergraduate - Campus"),(term="Headcount")/ printmiss misstext = "0";
keylabel n=" ";
format type $type. term $terms.;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1812 views
  • 2 likes
  • 3 in conversation