Announcement

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

  • "Too few quotes" error for tab2xl loop

    I have been trying to run a tab2xl loop for a range of variables. Please kindly refer to the following command that I have written.

    local hiv_tab1 "hiv_edu sexedu condoms_advpreg condoms_advstd condoms_advhiv condoms_advsafe condoms_disadvpleasure condoms_disadvtear condoms_disadvtrust condoms_disadvsafe condoms_disadvcomfort condoms_disadvmood condoms_usecasual condoms_usestable condoms_usemarital condoms_usemultiple condoms_useprostitute condoms_usepreg condoms_usesti condoms_usehiv hiv_infofamily hiv_infofriends hiv_infoteachers hiv_infomedia hiv_infobrochure hiv_infomedical hiv_infohealth hiv_inforeligious"

    local hiv_tab2 "marriage_idealage childbirth_idealage childbirth_idealsons childbirth_idealdaughters childbirth_idealnum hiv_s1 hiv_s2 hiv_s3 hiv_s4 hiv_s5 hiv_s6 hiv_s7 hiv_s8 hiv_s9 hiv_s10 hiv_s11 hiv_s12 hiv_s13 hiv_s14 hiv_s15 hiv_s16 hiv_s17 hiv_s18 hiv_s19 hiv_s20 hiv_s21 hiv_s22 hiv_s23 hiv_s24 hiv_family hiv_familydied hiv_friend hiv_testreliability hiv_fear hiv_nofamily hiv_noschool hiv_test hiv_testlast hiv_testfreq hiv_testwilling hiv_testparents"

    foreach var in `hiv_tab1' {
    tab2xl `var' using Section7_HIV_Tab.xlsx if survey_string == "0b", row(1) col(1) sheet("Baseline-`var'")
    }
    putexcel save
    putexcel clear

    foreach var in `hiv_tab2' {
    tab2xl `var' using Section7_HIV_Tab.xlsx if survey_string == "0b", row(1) col(1) sheet("Baseline-`var'")
    }
    putexcel save
    putexcel clear

    foreach var in `hiv_tab1' {
    tab2xl `var' using Section7_HIV_Tab.xlsx if survey_string == "1f", row(1) col(1) sheet("FU1-`var'")
    }
    putexcel save
    putexcel clear

    foreach var in `hiv_tab2' {
    tab2xl `var' using Section7_HIV_Tab.xlsx if survey_string == "1f", row(1) col(1) sheet("FU1-`var'")
    }
    putexcel save
    putexcel clear

    Originally, hiv_tab1 and hiv_tab2 were grouped together as hiv_tab. After several failed attempts to run the tab2xl command on the variables under hiv_tab, I tried to separate the variables into 2 groups. However, it still doesn't work.

    The error message shown is: "too few quotes, r(132)".

    Could someone please kindly advise?

    Many thanks in advance!
Working...
X