EpiData-list Digest, Vol 86, Issue 3
Hello,
Thank you for your reply, but I specify my problem: - Variables in the questionnaire Var1 ## Var2 ## Var3 ## Var4 ## Mean4 ##.##
- In CHECK file (or ANALYSIS) mean4 mean4 = (var1+var2+var3+var4)/4 end
- But sometimes, var2, for example, can fail (blank): in this case, "mean4" is the sum (Var1 to var4) divided by 3!
- My question is, how to count automatically (CHECK or ANALYSIS) the number of variables (var1 to var4) not missing?
Thank you for your help.
B. BRANGER, Nantes, France
-----Message d'origine----- De : epidata-list-bounces@lists.umanitoba.ca [mailto:epidata-list-bounces@lists.umanitoba.ca] De la part de epidata-list-request@lists.umanitoba.ca Envoyé : dimanche 19 décembre 2010 19:00 À : epidata-list@lists.umanitoba.ca Objet : EpiData-list Digest, Vol 86, Issue 3
Send EpiData-list mailing list submissions to epidata-list@lists.umanitoba.ca
To subscribe or unsubscribe via the World Wide Web, visit http://lists.umanitoba.ca/mailman/listinfo/epidata-list or, via email, send a message with subject or body 'help' to epidata-list-request@lists.umanitoba.ca
You can reach the person managing the list at epidata-list-owner@lists.umanitoba.ca
When replying, please edit your Subject line so it is more specific than "Re: Contents of EpiData-list digest..."
EpiData-list mailing list ___________________________________
Today's Topics:
1. Re: Number of variables not missing (epidata-list@lists.umanitoba.ca)
----------------------------------------------------------------------
Message: 1 Date: Sat, 18 Dec 2010 20:52:21 +0000 From: epidata-list@lists.umanitoba.ca Subject: [EpiData-list] Re: Number of variables not missing To: epidata-list@lists.umanitoba.ca Message-ID: AANLkTimm_vdw-KBwy03VcuDX5aXgUyZAB5k=JQbdzCU=@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1
Dear Bernard,
What do you think about count if [logical statement].
For example: count if km=. will return the number of km that are missing in the data set. Additionally you can list such list id if km=. Please let me know if this helps.
Tieble
On 18 December 2010 18:00, epidata-list-request@lists.umanitoba.ca wrote:
Send EpiData-list mailing list submissions to epidata-list@lists.umanitoba.ca
To subscribe or unsubscribe via the World Wide Web, visit http://lists.umanitoba.ca/mailman/listinfo/epidata-list or, via email, send a message with subject or body 'help' to epidata-list-request@lists.umanitoba.ca
You can reach the person managing the list at epidata-list-owner@lists.umanitoba.ca
When replying, please edit your Subject line so it is more specific than "Re: Contents of EpiData-list digest..."
EpiData-list mailing list ___________________________________
Today's Topics:
- Number of variables not missing (epidata-list@lists.umanitoba.ca)
Message: 1 Date: Sat, 18 Dec 2010 18:02:36 +0100 From: epidata-list@lists.umanitoba.ca Subject: [EpiData-list] Number of variables not missing To: epidata-list@lists.umanitoba.ca Message-ID: 6B03D7CCC9B74325BC1D373EEBCD70CF@Ordinateurfixe Content-Type: text/plain; charset="us-ascii"
Hello,
In EPIDATA ENTRY or ANALYSIS, to calculate an mean, it is easy to
calculate
a sum of several variables (the numerator)(even if some are missing), but
I
don't know calculate the number of non-missing variables (the denominator) as the command "NBVAL" in EXCEL. Thank you for helping me.
Bernard BRANGER, Nantes, France
EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
End of EpiData-list Digest, Vol 86, Issue 2
This is how I have done it in .chk
before file define n #.# define vtot ###.# end
mean4 before entry n = 0 vtot = 0 if var1 <> . then n = n+1 vtot = vtot + var1 endif if var2 <> . then n = n+1 vtot = vtot + var2 endif if var3 <> . then n = n+1 vtot = vtot + var3 endif if var4 <> . then n = n+1 vtot = vtot + var4 endif if n > 0 then mean4 = vtot / n else mean4 = . endif end end
Use float for n and vtot or else you have to convert them before calculating mean
In Analysis, you can use the iif function to simplify this.
gen n = iif(var1<>.,1,0)+iif(var2<>.,1,0) etc gen vtot = iif(var1<>.,var1,0)+ etc gen mean4 = iif(n>0,vtot/n,.)
Jamie
On 2010-12-27, Bernard wrote:
Hello,
Thank you for your reply, but I specify my problem:
- Variables in the questionnaire
Var1 ## Var2 ## Var3 ## Var4 ## Mean4 ##.##
In CHECK file (or ANALYSIS) mean4 mean4 = (var1+var2+var3+var4)/4 end
But sometimes, var2, for example, can fail (blank):
in this case, "mean4" is the sum (Var1 to var4) divided by 3!
- My question is, how to count automatically (CHECK or ANALYSIS) the number of variables (var1 to var4) not missing?
Thank you for your help.
participants (1)
-
epidata-list@lists.umanitoba.ca