LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 25 Apr 2007 11:58:15 -0400
Reply-To:     Magdalena Tolea <MTOLEA@EPI.UMARYLAND.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Magdalena Tolea <MTOLEA@EPI.UMARYLAND.EDU>
Subject:      Re: calculation of mean when number of measurement points varies
Comments: To: Jack Clark <JClark@CHPDM.UMBC.EDU>
In-Reply-To:  <456B52C41B724C41B96561D7AD283E7D052162@mail.chpdm.umbc.edu>
Content-Type: text/plain; charset=US-ASCII

Problem solved. Thank you Jack and Matthew. Magda

Magdalena Tolea University of Maryland, Baltimore DEPM/Gerontology PhD Program MSTF room 311A tel: 410-706-4046 fax:410-706-4433 email: mtolea@epi.umaryland.edu

>>> Jack Clark <JClark@CHPDM.UMBC.EDU> 4/25/2007 10:50 AM >>> Magda,

I would use the MEAN function in a DATA step. This logic makes sure there is at least one non-missing value. It should ignore other potential missing values and calculate the mean based on non-missing values.

Data new; Set old; If nmiss(of sbp1-sbp4) lt 4 then meansbp = mean(of sbp1-sbp4); Else meansbp = .; If nmiss(of dbp1-dbp4) lt 4 then meandbp = mean(of dbp1-dbp4); Else meandbp = . Run;

Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Magda Tolea Sent: Wednesday, April 25, 2007 10:35 AM To: SAS-L@LISTSERV.UGA.EDU Subject: calculation of mean when number of measurement points varies

Hello all,

Using NHANES data, I would like to calculate mean systolic blood pressure and mean diastolic blood pressure (per individual) for up to four measurement times. However, the number of and the sequence of these times vary. Is there an easy way to come up with these means, which would only use the valid values, such that if someone has only one measurement then the mean takes that value, if they have two measurements done then the mean only takes into account the two and so on?

I would like to see something like,

id sbp1 dbp1 sbp2 dbp2 sbp3 dbp3 sbp4 dbp4 meansbp meandbp

21005 . . . . . . . . . . 21006 100 58 94 46 102 54 . . 99 53 21007 . . . . 96 62 . . 96 62 21008 . . 102 80 . . 104 74 103 77 21009 124 88 124 86 112 84 . . 120 86 21010 128 86 138 82 134 84 . . 133 84 21011 . . . . . . . . . . 21012 126 64 120 66 122 64 . . 123 65 21013 108 64 108 66 108 68 . . 108 66

Thank you in advance,

Confidentiality Statement: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.


Back to: Top of message | Previous page | Main SAS-L page