Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Z_Scores calculation for Stunting_Wasting_Underweight

    Hi, I am following up the do.file from WHO to calculate the Z_Scores, and when I am reaching to the last step of igrowup_standard, the stata is telling me"Unrecognized command: igrowup_standard.


    import delimited "C:\Users\Macro\Desktop\NUTRITION\copy Antropometric_data of SOSOMA Minazi Feb March and April 2016 - Copy.csv"

    save "C:\Users\Macro\Desktop\NUTRITION\Nutrition_Prepar ed for Stun_Was_Und.dta"

    use "Nutrition_Prepared for Stun_Was_Und.dta"

    adopath + "Nutrition_Prepared for Stun_Was_Und.dta/"
    save "C:\Users\Macro\Desktop\NUTRITION\Nutrition_Prepar ed for Stun_Was_Und_WHO.dta"
    use "Nutrition_Prepared for Stun_Was_Und_WHO.dta"

    gen str60 reflib="Nutrition_Prepared for Stun_Was_Und.dta"
    lab var reflib "Directory of reference tables"

    gen str60 datalib="Nutrition_Prepared for Stun_Was_Und.dta"
    lab var datalib "Directory for datafiles"

    gen str30 datalab="mysurvey"
    lab var datalab "Working file"

    *Generating Sex basing on Names* 1=Male, 2=Female*
    ed amazinayumwana
    gen gender= amazinayumwana
    lab var gender " sex of children"

    *replace gender = "1" in 1 to 110*!Make it with the Data editor, ONE BY ONE

    encode gender, gen(gender1)
    recode gender1(1=1 "male")(2=2 " female"), gen(gender2)
    drop gender gender1
    rename (gender2)(gender)
    describe gender
    tab gender

    /* check the variable for "age" */
    rename (ageinmonths)(age)
    desc age
    summ age
    rename (agemonths)(agemons)
    summ agemons

    /* define your ageunit */
    gen str6 ageunit="months" /* or gen ageunit="days" */
    lab var ageunit "=days or =months"


    /* check the variable for body "weight" which must be in kilograms*/
    /* NOTE: if not available, please create as [gen weight=.]*/
    rename (poid)(weight)
    desc weight
    summ weight

    /* check the variable for "height" which must be in centimeters */
    /* NOTE: if not available, please create as [gen height=.]*/
    rename (taille)(height)
    desc height
    summ height


    /* check the variable for "measure"*/
    /* NOTE: if not available, please create as [gen str1 measure=" "]*/
    rename (muac)(measure)
    desc measure
    tab measure
    summ measure
    /* check the variable for "oedema"*/
    /* NOTE: if not available, please create as [gen str1 oedema="n"]*/
    gen str1 oedema= "n"
    lab var oedema "presence of oedema"
    desc oedema
    tab oedema


    /* check the variable for "sw" for the sampling weight*/
    /* NOTE: if not available, please create as [gen sw=1]*/
    gen sw=1
    lab var sw "created weigted sample"
    desc sw
    summ sw

    * Fill in the macro parameters to run the command */
    igrowup_standard reflib datalib datalab gender agemons ageunit weight height measure oedema sw









  • #2
    Have you installed the igrwoup_stata package? It's not part of official Stata. And it isn't on SSC either (although there is zscore06 on SSC which also does anthropometric z-scores using the WHO standards.) If you have installed it, where is it? If you just downloaded it into a separate directory, and didn't move those files into your ado path, then Stata won't find it. So you may need to move the files, or change your working directory to the directory where igrowup is installed.

    For what it's worth, -igrowup- is a Stata program in name only. The code was clearly written for SAS and a very literal-minded translation into Stata was undertaken. While it works, it requires the kind of elaborate setup you show in your post: a Stata-ish program would simply allow you to specify all that information through options. If you are a regular SAS user and are not comfortable with Stata but are forced to use it, then -igrowup- is probably great for you. But if you prefer the Stata approach, you would probably be better off using the -zanthro- package (-search zanthro- will get you a link to download it) which does everything -igrowup- does, and more, and actually works like a Stata program.

    Comment


    • #3
      I am conducting a research on the impact of access to microfinance on child nutrition and i have a problem with a stata command for calculating zscore for anthropometric measures.here is the command: zscore06, a(age_n_months) h( height_u_5) w( weight_u_5) measure(measure_style) MALE(1) FEMALE(1) SEXChild recum(1
      > ) o(oedema) oyes(1) ono(0)
      option s() required( this is comment it is bringing me)


      Comment


      • #4
        Change -SEXChild- to -s(SEXChild)-.

        Also, bear in mind that Stata is case-sensitive in nearly all things. So if the variable name is actually -sexchild-, then you have to write it in lower case in the commands as well. Perhaps more important, where you have MALE and FEMALE, Stata will be expecting male and female.
        Last edited by Clyde Schechter; 14 Dec 2021, 16:59.

        Comment


        • #5
          i have done so. zscore06, a(age_n_months) h( height_u_5) w( weight_u_5) measure(measure_style) MALE(1) FEMALE(1) s( SEXChild) rec
          > um(1) o(oedema) oyes(1) ono(0)
          option MALE() not allowed (this is the response)




          Comment


          • #6
            i have done as you said but its bringing another error saying that options . zscore06, a(age_n_months) h( height_u_5) w( weight_u_5) measure(measure_style) MALE(1) FEMALE(1) s( SEXChild) rec
            > um(1) o(oedema) oyes(1) ono(0)
            option MALE() not allowed

            Comment


            • #7
              It may be that your responses in #5 and #6 crossed with my edit to #4. Please read #4 where precisely this problem was anticipated and the solution provided.

              Comment


              • #8
                i have changed the letters to lower cases so i am executing all the commands

                Comment


                • #9
                  this is what i am getting after the execution process: . zscore06, a(age_n_months) h( height_u_5) w( weight_u_5) measure(measure_style) male(1) female(1) s( sexchild) rec
                  > um(1) o(oedema) oyes(1) ono(0)
                  value defined in male() does not appear in variable sexchild

                  . *************data cleaning*******************************
                  . gen missing= ( age_n_months==. |haz06==1 | waz06==.)
                  haz06 not found

                  Comment


                  • #10
                    this is what i am getting after the execution process: . zscore06, a(age_n_months) h( height_u_5) w( weight_u_5) measure(measure_style) male(1) female(1) s( sexchild) rec
                    > um(1) o(oedema) oyes(1) ono(0)
                    value defined in male() does not appear in variable sexchild

                    . *************data cleaning*******************************
                    . gen missing= ( age_n_months==. |haz06==1 | waz06==.)
                    haz06 not found

                    Comment


                    • #11
                      You specified that boys are identified by sexchild == 1 and girls by sexchild == 1. That's not possible. You need to give distinct values. Alternatively, the values in the variable sexchild do not include the number 1--which would also be a problem. So go back and figure out what the values of sexchild for boys and girls are in your data, and then specify those appropriately in the male() and female() options.

                      As a consequence of that, I think that -zscore06- did not actually run, so the variables haz06 and waz06 were not created.

                      Comment


                      • #12
                        help please sir

                        Comment


                        • #13
                          this is my do file, if possible please tell me where i need to make changes because i have done the neccessary changes you directed me
                          log using "C:\Users\FRANCIS CHIFUNDO LU\Downloads\chifundo log file.smcl", replace
                          clear
                          set more off
                          use "C:\Users\FRANCIS CHIFUNDO LU\Documents\HH_MOD_B.dta"
                          ************************************************** ************************************************** ************************************************** *******************
                          **************************Generating Variables***************************************** ***********************
                          ************Sex of the respondent**************************************** *******************
                          gen sex = hh_b03==1

                          ********Sex of the household head***********************************
                          gen sex_hhhead = hh_b04 if PID==1
                          replace sex_hhhead=0 if sex_hhhead==2
                          label var sex_hhhead "Sex of household head"
                          label define sex_hhheadlabel 0"female" 1 "male"
                          ************************************************** ************************************************** **********************
                          **************Household Size********************************************** ********
                          sort case_id
                          by HHID, sort: egen hhsize = count(PID)
                          label var hhsize "Household Size"
                          ************************************************** ************************************************** ******************************
                          **************Child characteristics*********************************** *************************************
                          **********Age of child****************************
                          generate months= hh_b05a*12 if hh_b05a<5
                          generate age_n_months=months+ hh_b05b
                          tab1 age_n_months
                          sum age_n_months
                          label variable age_n_months "Age of child in months"
                          tab age_n_months

                          ************AgeSQ***********************
                          generate AGESQ= age_n_months^2
                          label variable AGESQ "Age of child squared"
                          tab AGESQ

                          ***********Sex of a child**********************
                          gen sexchild=(hh_b03==1) if hh_b05a<5
                          label var sexchild "sex of the child"
                          label define sexchild 1 "male" 0 "female"
                          label val sexchild sexchild
                          tab sexchild
                          ************************************************** ************************************************** ************************************************** ******
                          ***********************Merging with Module C************************************************* ***
                          merge 1:1 case_id PID using "C:\Users\FRANCIS CHIFUNDO LU\Documents\HH_MOD_C.dta"
                          drop _merge
                          gen none =( hh_c09==1 )
                          gen plsc =( hh_c09==2 )
                          gen jce =( hh_c09==3 )
                          gen msce =( hh_c09==4 )
                          gen postsec =( hh_c09==5|hh_c09==6|hh_c09==7)

                          *Education of household head
                          gen Edu_head = hh_c09 if PID==1
                          gen none_hh = Edu_head if Edu_head==1
                          gen plsc_hh = Edu_head if Edu_head==2
                          gen jce_hh = Edu_head if Edu_head==3
                          gen msce_hh = Edu_head if Edu_head==4
                          gen postsec_hh = Edu_head if Edu_head==5|Edu_head==6|Edu_head==7|Edu_head==8|Ed u_head==9

                          clonevar hhid = case_id


                          label var none_hh " head's highest qualification is none"
                          label var plsc_hh " head's highest qualification is pslc"
                          label var jce_hh " head's highest qualification is jce"
                          label var msce_hh " head's highest qualification is msce"
                          label var postsec_hh "head's highest qualification is postsecondary"

                          label var none " highest qualification is none"
                          label var plsc " highest qualification is pslc"
                          label var jce " highest qualification is jce"
                          label var msce " highest qualification is msce"
                          label var postsec " highest qualification is postsecondary"
                          *******************Merging with Module D****************************************
                          merge 1:1 case_id PID using "C:\Users\FRANCIS CHIFUNDO LU\Documents\HH_MOD_D.dta"
                          keep if _merge==3
                          drop _merge
                          sort case_id
                          gen child_illness=1 if hh_d05a==1 & age_n_months<60
                          replace child_illness=0 if hh_d05a==2 & age_n_months<60
                          codebook child_illness

                          egen Child_illness=min(child_illness), by(case_id)
                          replace child_illness=Child_illness if child_illness==.
                          label var child_illness "Illness of child"
                          label define child_illness 1 "Yes" 0 "No"
                          label val child_illness child_illness
                          keep hhsize sex_hhhead age_n_months AGESQ sexchild case_id PID HHID none plsc jce msce postsec ///
                          none_hh plsc_hh jce_hh msce_hh postsec_hh Edu_head child_illness Child_illness

                          ************************************************** ************************************************** ********************************************
                          ****************Merging with Module E************************************************* *****************
                          merge 1:1 case_id PID using "C:\Users\FRANCIS CHIFUNDO LU\Documents\HH_MOD_E.dta"
                          drop _merge
                          gen emplo_head= hh_e06_4
                          replace emplo_head=1 if PID==1
                          replace emplo_head=2 if PID==1
                          label var emplo_head "Employment status of the household head"
                          label define emplo_headlabel 1 "Yes" 2 "No"
                          label values emplo_head emplo_headlabel
                          keep hhsize sex_hhhead age_n_months AGESQ sexchild case_id PID HHID none plsc jce msce postsec ///
                          none_hh plsc_hh jce_hh msce_hh postsec_hh Edu_head child_illness emplo_head Child_illness


                          ****************Merging with Module G_1***********************
                          merge m:m case_id using "C:\Users\FRANCIS CHIFUNDO LU\Documents\HH_MOD_G1.dta"
                          drop _merge
                          *Household consumption
                          egen HH_Food_Consumed=sum(hh_g05), by(HHID)
                          duplicates drop case_id HHID HH_Food_Consumed, force
                          sort case_id



                          **************Merging with Module a_hh_filt***************************
                          merge m:m case_id using "C:\Users\FRANCIS CHIFUNDO LU\Documents\hh_mod_a_filt.dta"
                          keep if _merge==3
                          drop _merge
                          gen LOCATION=0 if reside==1
                          replace LOCATION=1 if reside==2
                          label var LOCATION "Location of Household"
                          label define LOCATIONlabel 0 "Rural" 1"Urban"
                          label values LOCATION LOCATIONlabel
                          tab LOCATION
                          tab LOCATION, gen(LOCATION)
                          *****************Merging with Module S1********************************
                          merge m:m case_id using "C:\Users\FRANCIS CHIFUNDO LU\Documents\HH_MOD_S1.dta"
                          drop _merge
                          gen Loan_access=0
                          replace Loan_access=1 if hh_s01==1
                          label var Loan_access "Access to Loan"
                          label define Loan_accesslabel 1 "Accessed" 0 "No Access"
                          label values Loan_access Loan_accesslabel
                          #delimit
                          keep case_id HHID PID sex_hhhead hhsize age_n_months AGESQ sexchild none plsc jce msce postsec Loan_access
                          none_hh plsc_hh jce_hh msce_hh postsec_hh child_illness Edu_head HH_Food_Consumed emplo_head Child_illness
                          ; #delimit cr
                          sum hhsize sex_hhhead age_n_months AGESQ sexchild none plsc jce msce postsec ///
                          none_hh plsc_hh jce_hh msce_hh postsec_hh Edu_head child_illness emplo_head HH_Food_Consumed Child_illness Loan_access
                          *****************Merging with Module V*********************************
                          merge m:1 case_id PID using "C:\Users\FRANCIS CHIFUNDO LU\Documents\HH_MOD_V.dta"
                          drop _merge
                          sort case_id
                          gen weight_u_5= hh_v08
                          gen height_u_5= hh_v09
                          label variable weight_u_5 "weight of the child"
                          label variable height_u_5 "height of the child"
                          label values weight_u_5 weight_u_5label
                          label values height_u_5 height_u_5label
                          gen oedema= ( hh_v14==1)
                          gen measure_style= ( hh_v11==1)
                          *******************Zscore computation***************************
                          zscore06, a(age_n_months) h( height_u_5) w( weight_u_5) measure(measure_style) male(1) female(1) s( sexchild) recum(1) o(oedema) oyes(1) ono(0)
                          *************data cleaning*******************************
                          gen missing= ( age_n_months==. |haz06==1 | waz06==.)
                          generate outrange_haz = (haz06< -6 | haz06 > 3)
                          replace outrange_haz=. if haz06==.
                          generate outrange_waz = (waz06< -5 | waz06 > 5)
                          replace outrange_waz=. if waz06==.
                          drop if missing==1 | outrange_haz==1 | outrange_haz==1

                          #delimit
                          keep case_id HHID PID sex_hhhead hhsize age_n_months AGESQ sexchild none plsc jce msce postsec
                          none_hh plsc_hh jce_hh msce_hh postsec_hh child_illness Child_illness weight_u_5 height_u_5 oedema Edu_head
                          measure_style haz06 waz06 bmiz06 missing outrange_haz outrange_waz HH_Food_Consumed LOCATION LOCATION1 LOCATION2 Loan_access emplo_head
                          ; #delimit cr

                          ************************Descriptive statistics
                          sum waz haz whz Loan_access HH_Food_Consumed LOCATION LOCATION1 LOCATION2 sex_hhhead hhsize age_n_months none_hh plsc_hh jce_hh msce_hh postsec_hh SEXChild child_illness
                          ************************************************** ************************************************** *************************************************
                          ***********************Summary statistics by Gender******************************************** ********************************
                          bysort sex_hhhead : sum HH_Food_Consumed Loan_access none plsc jce msce postsec none_hh plsc_hh jce_hh msce_hh postsec_hh hhsize age_n_months sexhild waz haz whz child_illness

                          ************************Summary statistics by location****************************************** *******************************
                          bysort LOCATION: sum HH_Food_Consumed Loan_access none plsc jce msce postsec none_hh plsc_hh jce_hh msce_hh postsec_hh hhsize age_n_months sexchild waz haz whz child_illness

                          ************************Summary statistics by household access to Loan********************************************** ************
                          bysort Loan_access: sum HH_Food_Consumed none plsc jce msce postsec none_hh plsc_hh jce_hh msce_hh postsec_hh hhsize age_n_months sexhild waz haz whz child_illness LOCATION
                          ************************regression analysis****************************************** ******************************
                          sureg (haz Loan_access LOCATION LOCATION1 LOCATION2 HH_Food_Consumed emplo_head child_illness none plsc jce msce postsec none_hh plsc_hh jce_hh msce_hh postsec_hh hhsize age_n_months sexchild)(waz Loan_access LOCATION LOCATION1 LOCATION2 HH_Food_Consumed emplo_head none plsc jce msce postsec none_hh plsc_hh jce_hh msce_hh postsec_hh child_illness hhsize age_n_months sexchild)
                          estat summarize
                          log close

                          Comment


                          • #14
                            Code:
                            zscore06, a(age_n_months) h( height_u_5) w( weight_u_5) measure(measure_style) male(1) female(0) s( sexchild) recum(1) o(oedema) oyes(1) ono(0)
                            is the solution to your immediate concern expressed in #10.

                            It is not possible to more broadly critique this extensive block of code, as only you would know what is in these data sets and what the numerous variables with obscure names mean.

                            There is however a glaring error that occurs at least three times that I saw (and perhaps elsewhere that I missed). You are using -merge m:m- which is, for practical purposes, always wrong. Not knowing what is in the data sets that are being merged in these commands, I cannot say what the correct replacement for -merge m:m- would be in these particular instances. Most likely you need to add more variables to the list of variables that are to be matched across the data sets being combined so that you can then use merge 1:m, m:1, or 1:1. Or, you may want to match every observation in each data set with every observation in the other data set that has the same value of case_id--if so, you need the -joinby- command, not -merge-. For more detailed advice on how to fix this problem, go to the PDF documentation for -merge- that comes installed with Stata and read the section called "Troubleshooting m:m merges."

                            Comment


                            • #15
                              thanks so much Clyde!! I will surely do it and will come back to you soon

                              Comment

                              Working...
                              X