Announcement

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

  • Making "dataex" command work to export lines of code to statalist

    Hello,

    I can get dataex to work when all I need to do is get state to make a list of values, but I can't make dataex work when I'm trying to export lines of code.

    If I put dataex in the same line as my code, I'm told 'variable not found'.
    If I put dataex in a line above my code, I'm told 'input statement exceeds linesize limit. Try specifying fewer variables'. See screenshot below:
    Click image for larger version

Name:	Screen Shot 2019-03-20 at 10.52.57.png
Views:	1
Size:	26.6 KB
ID:	1489091




    This is the code I would like to export using dataex:
    gen occsoc_noX = subinstr(occsoc, "X", "0", .)
    destring occsoc_noX, gen (occsoc_num)

    drop occsoc_noX
    gen occsoc_noblanks = occsoc
    replace occsoc_noblanks = strtrim(occsoc_noblanks)
    gen occsoc_noX = subinstr(occsoc_noblanks, "X", "0", .)
    destring occsoc_noX, gen (occsoc_num)
    What should I do? Have I perhaps misunderstood the function of the command 'dataex'?

    Thanks for your time and consideration.

    Rosa

  • #2
    Yes, this is a misunderstanding of dataex. dataex makes it easier to give data examples that people can use by showing code within CODE delimiters that produces that data as a dataset.

    To show code within CODE delimiters, just use the editing keys directly as explained at 12.3 in
    https://www.statalist.org/forums/help#stata

    Code:
    gen occsoc_noX = subinstr(occsoc, "X", "0", .)
    destring occsoc_noX, gen (occsoc_num)
    
    drop occsoc_noX
    gen occsoc_noblanks = occsoc
    replace occsoc_noblanks = strtrim(occsoc_noblanks)
    gen occsoc_noX = subinstr(occsoc_noblanks, "X", "0", .)
    destring occsoc_noX, gen (occsoc_num)
    Last edited by Nick Cox; 20 Mar 2019, 04:10.

    Comment


    • #3
      This explains it, thanks a lot Nick.

      Comment


      • #4
        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input byte region int(date year) byte(day month season hw) str11 hw_sev str70 chapter byte deaths
        2 9497 1986 1 1 1 0 "no-heatwave" "Certain Infect.Parasitic dis (A00-B99)"                                 3
        1 9497 1986 2 3 1 0 "no-heatwave" "Neoplasms (C00-C48)"                                                    5
        1 9497 1986 1 1 2 1 "no-heatwave" "Endocrine - Metabolic diseases (E00-E89)"                               1
        1 9497 1986 3 4 1 0 "no-heatwave" "Disease of the Blood - Immune (D50 - D80)"                              0
        1 9497 1986 1 1 1 0 "no-heatwave" "Mental & Behaviour Disorder (F00 - F99))"                               5
        2 9497 1986 5 2 1 1 "no-heatwave" "Diseases of the Nurvous - Eye - Ear (G00 - G99; H00-H95)"               0
        2 9497 1986 1 1 2 1 "no-heatwave" "Diseases of Circulatory System (I00 - I99)"                             3
        2 9498 1986 3 5 2 0 "no-heatwave" "Endocrine - Metabolic diseases (E00-E89)"                               5
        2 9498 1986 2 1 2 0 "no-heatwave" "Disease of the Blood - Immune (D50 - D80)"                              1
        1 9498 1986 1 2 1 0 "no-heatwave" "Mental & Behaviour Disorder (F00 - F99))"                               2
        1 9498 1986 2 1 1 1 "no-heatwave" "Diseases of the Nurvous - Eye - Ear (G00 - G99; H00-H95)"               5
        2 9498 1986 5 2 2 0 "no-heatwave" "Diseases of Circulatory System (I00 - I99)"                             3
        2 9498 1986 2 1 1 0 "no-heatwave" "Diseases Respiratory system (J00-J99)"                                  1
        1 9498 1986 2 3 2 1 "no-heatwave" "Disease of Digestive System (K00 - K93)"                                2
        1 9498 1986 5 6 1 0 "no-heatwave" "Disease of the Genitourinary System (N00 - N99)"                        4
        2 9498 1986 3 7 1 1 "no-heatwave" "External cause - Accidents - Harm (V00-V99; W00-W99; X00-X99; Y00-Y98)" 2
        1 9498 1986 1 2 2 0 "no-heatwave" "Condition - originating Perinatal period (P0-P96)"                      4
        2 9498 1986 2 1 1 1 "no-heatwave" "Congenital Malformations (Q00-Q99)"                                     2
        end
        format %tddd-Mon-YY date

        Dear experts,

        I would like to run a Poison regression Model to assess mortality by heat wave, for each disease level (which are many). The data shown above is snippet. How Can I run a Poisson regression for each disease and present the model output for all diseases.

        Comment


        • #5
          Dear experts,

          I would like to run a Poison regression Model to assess mortality by heat wave, for each disease level (which are many). The data shown above is snippet. How Can I run a Poisson regression for each disease and present the model output for all diseases.

          Comment


          • #6
            Given that your real interest is in Poisson [not Poison] regression -- not in how to get dataex to work -- you should start a new thread with an appropriate title.

            That said, I don't think you will get good answers without showing at least a token effort to get started.

            Comment

            Working...
            X