BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hello,

I would like to use the Missing option in the different classes below.  

I want Age/Sex/Race/Insurance/Underly (Missing value inclusion)  and Oxy/ICU/Incub/Ecmo/Died(Missing value exclusion). In addition, is there a way to get the SUM of each class in the Tabulate statement too?  Please guild me a way to do it.  Thanks.

 

proc tabulate data=ARI_UC_Elg_IDs;
   class Age Sex race Insurance oxy ICU Intub Ecmo Died Underly;
   tables (Age Sex race Insurance oxy ICU Intub Ecmo Died)*(n colpctn*f=4.2), Underly;
   where Age_group in (1,2,3);
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

You can have multiple CLASS statements, so to control MISSING option you can do:

proc tabulate data=ARI_UC_Elg_IDs;
   class Age Sex race Insurance Underly / missing ;
   class oxy ICU Intub Ecmo Died ;
   tables (Age Sex race Insurance oxy ICU Intub Ecmo Died)*(n colpctn*f=4.2), Underly;
   where Age_group in (1,2,3);
run;

There are examples in the docs about getting a sum.  You need to use a VAR statement to add an analytical variable.  See e.g. : https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p13k5zc709o4t3n1k9u2s7dsnzv9.htm 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Bart Jablonski and I present 53 (+3) ways to do a table lookup on Wednesday Sep 18.
Register now at https://www.basug.org/events.

View solution in original post

3 REPLIES 3
Quentin
Super User

You can have multiple CLASS statements, so to control MISSING option you can do:

proc tabulate data=ARI_UC_Elg_IDs;
   class Age Sex race Insurance Underly / missing ;
   class oxy ICU Intub Ecmo Died ;
   tables (Age Sex race Insurance oxy ICU Intub Ecmo Died)*(n colpctn*f=4.2), Underly;
   where Age_group in (1,2,3);
run;

There are examples in the docs about getting a sum.  You need to use a VAR statement to add an analytical variable.  See e.g. : https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p13k5zc709o4t3n1k9u2s7dsnzv9.htm 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Bart Jablonski and I present 53 (+3) ways to do a table lookup on Wednesday Sep 18.
Register now at https://www.basug.org/events.
ballardw
Super User

The ALL keyword on the table statement determines getting the statistics for all levels of a class variable combined.

 

SUM is reserved for VAR variables. To get a total N please see this:

proc tabulate data=sashelp.class;
   class sex age;
   table sex*(n pctn)  ,
         age 
   ;
   table (sex all)*(n pctn)  ,
         age 
   ; 
   table sex*(n pctn)  ,
         age all
   ;
   table (sex all)*(n pctn)  ,
         age all
   ;
run;

You weren't very clear as to which particular "sum" you might want so I include example without any "all" and then examples of each dimension.

Astounding
PROC Star

Also note, if an observation is removed because of a missing value, it is totally removed.  It will be removed for the calculations based on other variables, even when those other variables do not have missing values.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 522 views
  • 6 likes
  • 4 in conversation