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 

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 

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 3 replies
  • 1169 views
  • 6 likes
  • 4 in conversation