Announcement

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

  • Ruth-Alma Turkson-Ocran
    replied
    Steven Spivack Depending on what you want to examine, the following commands can handle analytic weights:

    tabstat (aweights, fweights)

    tabulate (aweights , fweights ) ...also goes with summarize...

    table ( fweights, iweights, and pweights)

    These are the few that come to mind...

    Leave a comment:


  • Steven Spivack
    replied
    Thanks for these examples. I am running into another problem with the table1 command though, which is that it does not appear to allow for the use of analytical weights. Do you know of another command that allows for this? I tried tabout but you need to survey set the data first which is not applicable for these analyses.

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    I forgot to add a sample of the dataset:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(age_p sex_r married edu_cat poor2 emp_stat) byte notcov float(usupl stay_us black_african)
    80 0 0 1 1 0 2 1 . 0
    56 0 1 3 3 0 2 1 1 0
    46 0 1 3 3 1 2 1 . 0
    22 0 0 2 3 1 2 1 . 0
    31 0 0 2 3 0 2 1 . 0
    56 0 0 1 3 1 2 1 . 0
    58 0 0 3 3 1 2 1 . 0
    55 0 0 2 1 0 2 1 . 0
    56 0 1 3 3 0 2 1 . 0
    58 0 1 1 2 0 2 1 . 0
    78 0 0 1 2 0 2 1 2 0
    62 0 1 1 3 0 2 1 . 0
    33 0 0 2 3 1 2 0 . 0
    59 0 1 1 3 1 1 0 . 0
    68 0 0 2 1 0 2 1 . 0
    20 0 0 1 1 0 1 1 . 0
    73 0 0 1 2 0 2 1 . 0
    64 0 0 2 3 1 2 1 . 0
    67 0 0 3 2 1 2 0 . 0
    55 0 0 3 3 0 1 0 . 0
    60 0 0 3 3 1 2 1 . 0
    62 0 0 1 2 0 1 1 . 0
    27 0 0 2 3 1 1 0 . 0
    76 0 0 . 3 0 2 1 1 1
    51 0 0 1 3 1 1 0 . 0
    35 0 0 2 3 1 2 1 2 1
    34 0 1 3 3 1 2 1 . 0
    45 0 1 1 3 0 1 1 . 0
    67 0 0 3 3 0 2 1 2 0
    24 0 0 3 3 0 2 1 . 0
    48 0 0 3 3 1 2 1 . 0
    38 0 0 1 3 0 2 1 2 1
    27 0 0 3 3 1 2 1 . 0
    54 0 0 1 2 1 2 1 . 0
    61 0 0 1 2 0 2 1 . 0
    33 0 1 3 3 1 2 1 . 0
    56 0 0 1 2 1 2 1 . 0
    28 0 0 2 1 0 2 1 . 0
    77 0 0 2 3 0 2 1 . 0
    81 0 0 1 3 0 2 1 . 0
    32 0 0 2 2 1 2 1 2 1
    58 0 1 2 3 1 2 1 . 0
    50 0 1 1 3 0 2 1 . 0
    35 0 1 2 2 0 2 1 . 0
    52 0 0 3 3 1 2 1 . 0
    59 0 1 3 3 1 2 1 . 0
    35 0 1 . 1 0 1 0 2 0
    59 0 0 1 1 0 2 1 . 0
    50 0 1 1 3 1 2 1 . 0
    29 0 0 1 1 0 2 1 2 1
    52 0 0 1 3 1 2 1 2 0
    25 0 0 1 3 1 2 1 . 0
    59 0 0 2 3 1 2 1 . 0
    30 0 0 1 1 1 2 1 1 1
    36 0 1 2 3 0 2 1 . 0
    28 0 0 2 2 1 1 0 . 0
    53 0 1 2 2 0 1 1 . 0
    25 0 1 3 2 0 2 0 . 0
    28 0 0 1 1 1 2 1 2 0
    34 0 1 3 3 1 2 1 1 0
    46 0 0 1 2 0 2 1 . 0
    35 0 1 1 3 1 1 0 2 1
    78 0 0 1 2 0 2 1 . 0
    81 0 1 2 3 0 2 1 . 0
    32 0 1 3 3 1 2 1 . 0
    30 0 0 2 2 1 1 1 . 0
    20 0 0 2 1 1 1 1 1 1
    70 0 1 2 3 0 2 1 . 0
    30 0 1 1 1 1 2 0 1 1
    38 0 0 3 3 1 2 1 . 0
    36 0 0 1 2 1 2 0 1 1
    78 0 0 1 3 0 2 1 . 0
    74 0 0 1 2 0 2 1 . 0
    27 0 0 2 3 1 1 0 . 0
    44 0 0 1 3 1 1 0 . 0
    65 0 1 2 3 0 2 1 . 0
    36 0 0 2 3 1 2 1 . 0
    25 0 0 2 1 0 2 1 . 0
    63 0 0 2 2 0 1 0 . 0
    32 0 0 3 3 1 2 1 . 0
    71 0 1 1 3 0 2 1 . 0
    82 0 1 1 3 0 2 1 . 0
    65 0 1 1 3 1 2 1 . 0
    46 0 1 2 2 1 1 0 . 0
    31 0 0 3 1 0 2 1 1 1
    55 0 1 1 3 1 1 0 2 1
    55 0 1 1 2 0 1 1 2 0
    57 0 1 2 2 0 2 1 . 0
    27 0 1 2 3 1 2 1 2 1
    37 0 1 2 3 1 2 1 . 0
    31 0 0 1 3 1 1 1 1 0
    69 0 0 2 2 0 2 1 . 0
    21 0 0 1 1 0 1 1 . 0
    20 0 0 2 3 1 2 0 . 0
    60 0 0 3 3 0 2 1 . 0
    36 0 1 1 2 1 1 1 2 1
    36 0 1 3 2 1 2 1 . 0
    24 0 0 1 3 0 1 0 . 0
    66 0 0 2 2 1 2 1 . 0
    26 0 1 1 1 1 1 1 . 0
    end
    label values age_p pep031x
    label values sex_r sex_r
    label def sex_r 0 "0: Females", modify
    label values married married
    label def married 0 "0: Not Married", modify
    label def married 1 "1: Currently Married", modify
    label values edu_cat edu_cat
    label def edu_cat 1 "1: High School", modify
    label def edu_cat 2 "2: College", modify
    label def edu_cat 3 "3: Graduate School", modify
    label values poor2 poor2
    label def poor2 1 "1: Poor", modify
    label def poor2 2 "2: Near Poor", modify
    label def poor2 3 "3: Not Poor/Near Poor", modify
    label values emp_stat emp_stat
    label def emp_stat 0 "0: Unemployed", modify
    label def emp_stat 1 "1: Employed", modify
    label values notcov pep394x
    label def pep394x 1 "1 Not covered", modify
    label def pep394x 2 "2 Covered", modify
    label values usupl usupl
    label def usupl 0 "0: Do not have a usual place", modify
    label def usupl 1 "1: Have a usual place", modify
    label values stay_us stay_us
    label def stay_us 1 "1: ≥ 5 yrs but < 10 yrs", modify
    label def stay_us 2 "2: ≥ 10 years", modify
    label values black_african black_african
    label def black_african 0 "0: Not Black African", modify
    label def black_african 1 "1: Black African", modify
    Also, please delete racreci3 from the code in the previous post. The true code should be:

    Code:
    tabxml, ivc(age_p) ivd(sex_r married edu_cat poor2 emp_stat notcov usupl stay_us) order(age_p sex_r married edu_cat poor2 emp_stat notcov usupl stay_us) save("/location_filename_$datentime") split(sex_r) options(n per) display bold justify(c) pval sp

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    On another note, I am using tabxml in Stata 14.2 and trying to do another Table 1 by sex. When using variations of this code:

    Code:
     tabxml, ivc(age_p) ivd(sex_r married racreci3 edu_cat poor2 emp_stat notcov usupl) order(age_p sex_r racreci3 married edu_cat poor2 emp_stat notcov usupl) save("/location_filename_$datentime") split(sex_r) options(n per) display bold justify(c) pval sp
    I keep getting errors such as: "invalid subpop() option" when I try using the subcond option. I also get this error:

    Code:
    Table contains a zero in the marginals.
      Statistics cannot be computed.
    conformability error
    r(503);
    when I use this code:

    Code:
     tabxml, ivc(age_p) ivd(sex_r married racreci3 edu_cat poor2 emp_stat notcov usupl) order(age_p sex_r racreci3 married edu_cat poor2 emp_stat notcov usupl) save("/location_filename_$datentime") split(sex_r) options(n per) display bold justify(c) pval sp
    What am I doing wrong?

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    Hi Steven,

    I know of comparing three groups. I believe you can use the
    Code:
    split(varname)
    option to do that...(I don't get a p-value for comparing two groups if that helps) If anyone has been able to figure out how to get the significance levels for that, it would be nice, otherwise, I use the option:
    Code:
    display
    to get the p-values in the display window and manually enter them in your table. Hope this helps

    Leave a comment:


  • Steven Spivack
    replied
    Hi Mark

    Can this command be used to compare three groups or only two. For example, if I have three groups and I compare means between them, is the program running a ttest or anova. I believe the program accurately runs an anova but I just wanted to be sure.

    Steven

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    Thanks Mark, Sorry about the super late reply on this, I thought I replied. The tabxml worked great for me.

    Leave a comment:


  • Mark Chatfield
    replied
    I have just become aware of the user written -tabxml- command, which can deal with survey data.

    net install sg100, from(http://www.stata.com/stb/stb47)
    *to avoid matsum error message

    net install tabxml.pkg

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    Thank you. For number 2, I just did the following:

    table1_mc if immig_status==1, by (sex) vars(age contn \ marital_stat cat \ race cat \ education cat \ income cat \) onecol
    table1_mc if immig_status==0, by (sex) vars(age contn \ marital_stat cat \ race cat \ education cat \ income cat \) onecol

    These gave me two different tables which were exported into excel and I then manually filled the table above by copying and pasting side by side into one excel sheet to look like the sample table above.

    Leave a comment:


  • Mark Chatfield
    replied
    Hi Ruth
    1. table1_mc is an extension and improvement on table1. For more, type . viewsource table1_mc.ado
    2. You would need to use either command twice.

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    Thanks Mark, I have a couple more follow up questions:

    1. What are the differences/advantages of using the table1_mc command/option over the older table1 command? and

    2. Is there a way using either command to stratify by more than one variable e.g. when using: by(varname) and not by(var1 var2). For example, I used the following code to stratify by immigrant status:

    table1, by (immig_status) vars(age contn \ sex bin \ marital_stat cat \ race cat \ education cat \ income cat \) onecol

    However, I would like to stratify by both immigrant status and sex. (see table below) What would be the best way to go about this? Any suggestions for/modifications to the above code to be able to do this?


    Click image for larger version

Name:	Screen Shot 2018-03-29 at 1.16.53 AM.png
Views:	1
Size:	38.5 KB
ID:	1436624

    Leave a comment:


  • Rich Goldstein
    replied
    of the various use-written commands in this area, I believe that only -meantab- accepts pweights; whether it also does everything else you want, I'm not sure; use -search- to find and download

    Leave a comment:


  • Mark Chatfield
    replied
    Hi Ruth, fweights are allowed ... which would only help with the simplest survey data. That's all I'm afraid.

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    Is there a way to use this command or the older Table1 command on survey data (e.g. with the svy command) We desperately need that

    Leave a comment:


  • Rasool Baloch
    replied
    Hi Mark,

    I have looked the code and tried to add option table(before|after) is not working. I think this option is not implemented. In addition it should be helpful if the each factors N (denominator) will be added in the same table after each variable instead of a separate table.

    Leave a comment:

Working...
X