Help using Base SAS procedures

exclude observations from reslults in proc tabulate

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

exclude observations from reslults in proc tabulate

Hi!

 

I'm trying to make a PROC TABULATE for a big amount of observations (60 000), and there are few missing values for some variables... I want to exclude these missing values from the stats I calculate, but I don't want to delete de rows! Some observations can be used for one variable and not the other... (n=6500 instead of 6480 (there are 20 missing values))

 

Code:

 

proc tabulate data=Recyc.aqhc_cc;
class     groupe_enrobe         Calibre        R;
var        ecart_Ta_5               ecart_Ta_080             ecart_TG              ecart_PourBitume;
table (groupe_enrobe)*(calibre),(R    All)*(n)    (R    All)*(ecart_Ta_5    ecart_Ta_080    ecart_TG                                                                                                                                                                                  ecart_PourBitume)*(std);
run;

 

I want n to be counted without missing values of variables... Same for std...

 

Thanks for your help!!! Smiley Happy

Marie-Christine


Accepted Solutions
Solution
‎08-16-2017 09:28 AM
Occasional Contributor
Posts: 19

Re: exclude observations from reslults in proc tabulate

Posted in reply to PaigeMiller

Hi! thanks for the quick answer!

I thought the same, but when I did the proc capability statement, I found different n ans std... So I investigated, and I found 17 missing values (with proc means) for a particular variable and class... the "n" was not the right one in proc tabulate... :\

View solution in original post


All Replies
Respected Advisor
Posts: 3,058

Re: exclude observations from reslults in proc tabulate

As far as I know, PROC TABULATE does not include missings in its statistics, and furthermore the missing are not included in the calculation of N.

 

So as far as I can see, you don't need to do anything different.

--
Paige Miller
Solution
‎08-16-2017 09:28 AM
Occasional Contributor
Posts: 19

Re: exclude observations from reslults in proc tabulate

Posted in reply to PaigeMiller

Hi! thanks for the quick answer!

I thought the same, but when I did the proc capability statement, I found different n ans std... So I investigated, and I found 17 missing values (with proc means) for a particular variable and class... the "n" was not the right one in proc tabulate... :\

Occasional Contributor
Posts: 19

Re: exclude observations from reslults in proc tabulate

I found it! N is excluded EXCEPT for n and nmiss in proc tabulate! thank you!
Respected Advisor
Posts: 3,058

Re: exclude observations from reslults in proc tabulate


bemariec wrote:
I found it! N is excluded EXCEPT for n and nmiss in proc tabulate! thank you!

I'm sorry but I don't understand this statement.

 

Do you mean that missing values are excluded?

--
Paige Miller
Occasional Contributor
Posts: 19

Re: exclude observations from reslults in proc tabulate

Posted in reply to PaigeMiller
Sorry! yess! Missing values are excluded Except for n ans nmiss, where missing values are included
Super User
Posts: 13,583

Re: exclude observations from reslults in proc tabulate

[ Edited ]

bemariec wrote:
Sorry! yess! Missing values are excluded Except for n ans nmiss, where missing values are included

 

I think you need to say something about which specific variables you  are discussing as CLASS variables with missing values are excluded:

data junk;
   input x;
datalines;
.
1
1
1
.
3
3
3
3
2
;
run;

proc tabulate data=junk;
   class x;
   table x all,n;
run;

10 obs in, 8 reported on.

 

 

Tabulate by default will exclude all rows with ANY of the class variables missing.

So when you look at individual variables such as with proc means or freq the class variables values will ALL show.

data junk;
   input x y;
datalines;
. 1
1 2
1 3
1 .
. 5
3 1
3 1
3 .
3 1
2 1
;
run;

proc tabulate data=junk;
   class x Y;
   table x *y,n;
run;

proc means data=junk n;
   var x y;
run;

Tabulate: 6 records, Means 8 values for each of x and y.

 

 

So you might want to consider providing some example data and what the desired result is.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 268 views
  • 0 likes
  • 3 in conversation