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
Onyx | Level 15

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
Onyx | Level 15

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



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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 312 views
  • 0 likes
  • 2 in conversation