BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nasser_DRMCP
Lapis Lazuli | Level 10

Hello,

 

I get a dataset that holds this data (among others rows)

trim_enctx_encs
390,0119385478
390,0083772957
390,0100340886
390,0057855255
390,0072882861

so, the mean of tx_enc for the trim_enc 39 should be 0.0086 but in the output window, the mean displayed is 0.005428

because sas considers tx_enc 0 for s=2 , 3,  4 (missing row are included in the calculation)

How can I exclude missing rows ?

thanks in advance for your help

regards,

Nasser

 

proc tabulate data=encaiss_8dertrim_detail order=DATA ;

title j=l TAUX MOYEN DES 8 DERNIERS TRIMSTRES CTX (detail) ;

where s > 0 ;

class s trim_enc ;

var tx_enc ;

table trim_enc="" , s=""*tx_enc=""*mean=""*f=10.5 ;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

Hi @Nasser_DRMCP 

 

Could you elaborate a bit more about your issue?

 

when I ran your code (with ALL keyword added for summary):

data encaiss_8dertrim_detail;
input trim_enc	tx_enc	s;
cards;
39	0.011938547	8
39	0.008377295	7
39	0.010034088	6
39	0.005785525	5
39	0.007288286	1
;
run;

ods html;
proc tabulate data=encaiss_8dertrim_detail order=DATA ;
  title j=l "TAUX MOYEN DES 8 DERNIERS TRIMSTRES CTX (detail)" ;
  where s > 0 ;
  class s trim_enc ;
  var tx_enc ;
  table trim_enc="" , (s="" ALL)*tx_enc=""*mean=""*f=10.5 ;   /* ALL added*/
quit;

SAS returned following output:

------------------------------------------------------------------------------------------------
|                            |    8     |    7     |    6     |    5     |    1     |   All    |
|----------------------------+----------+----------+----------+----------+----------+----------|
|39                          |   0.01194|   0.00838|   0.01003|   0.00579|   0.00729|   0.00868|
------------------------------------------------------------------------------------------------

and the average is as you wrote 0.0086.

 

All the best

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

1 REPLY 1
yabwon
Amethyst | Level 16

Hi @Nasser_DRMCP 

 

Could you elaborate a bit more about your issue?

 

when I ran your code (with ALL keyword added for summary):

data encaiss_8dertrim_detail;
input trim_enc	tx_enc	s;
cards;
39	0.011938547	8
39	0.008377295	7
39	0.010034088	6
39	0.005785525	5
39	0.007288286	1
;
run;

ods html;
proc tabulate data=encaiss_8dertrim_detail order=DATA ;
  title j=l "TAUX MOYEN DES 8 DERNIERS TRIMSTRES CTX (detail)" ;
  where s > 0 ;
  class s trim_enc ;
  var tx_enc ;
  table trim_enc="" , (s="" ALL)*tx_enc=""*mean=""*f=10.5 ;   /* ALL added*/
quit;

SAS returned following output:

------------------------------------------------------------------------------------------------
|                            |    8     |    7     |    6     |    5     |    1     |   All    |
|----------------------------+----------+----------+----------+----------+----------+----------|
|39                          |   0.01194|   0.00838|   0.01003|   0.00579|   0.00729|   0.00868|
------------------------------------------------------------------------------------------------

and the average is as you wrote 0.0086.

 

All the best

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation