Announcement

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

  • Double quotes in long string scalar halting putdocx output

    I have a string scalar that I need to pass into a putdocx. Whenever a double quote or some special characters like a semicolon is encountered, the line gets interrupted in the final .docx. It shows up fine in a -di- command however. I tried passing a with a `=char(34)' within the string scalar for the double quotes (based on pointers from posts and discussion by Bjarte Aagnes, but that does not solve the issue. This is related to my earlier post from yesterday (which I managed to solve on my own and will share shortly to close the loop on that post). But this is the one last piece of that puzzle I cannot get around. For the sake of clarity, I have only included blocks that are relevant.

    Code:
    scalar ngstext = `": (A) Co-mutations and structural alterations in patients with any co-mutations ordered first by TP53 mutation class (TP53MIS vs. TP53NMIS) and then by best response to first line therapy. Structural alterations/losses predominated with CUX1, EZH2, and APC. Genes corresponding to the "EPI7" signature include CBL, CUX1, DNMT3A, EZH2, NF1, KRAS and TET2. (B) TP53 VAF % by key covariates. EPI7 gene alterations (b), CUX1 alterations (d) and 2+ monosomies (f) were all associated with significantly higher TP53 VAFs."'
    di ngstext  // shows up fine here
    Rest of the code including the 4 other scalars I passed with it.

    Code:
    tokenize "ngs os2 km4 forest mv"
    local labels "scalar(ngstext) scalar(os2text) scalar(km4text) scalar(foresttext) scalar(mvtext)"
    forvalues j = 1/`:word count `labels'' {
        local label : word `j' of `labels'
        global Fig`j' "Figure `j'"
        global call``j'' " (See Fig.`j')"
        global text`j' = `label'
    }
    macro list
    
    // Main manuscript Figure legends
    *---------------------------------
    putdocx paragraph, style(Heading1) font("arial", 13, black) halign(both)
    putdocx paragraph, font("arial", 11, black) spacing(line, 22pt)
    putdocx text ("${Fig1}$text1")
    What I am getting in the final docx:

    Code:
    Figure 1: (A) Co-mutations and structural alterations in patients with any co-mutations ordered first by TP53 mutation class (TP53MIS vs. TP53NMIS) and then by best response to first line therapy. Structural alterations/losses predominated with CUX1, EZH2, and APC. Genes corresponding to the

  • #2
    Figured it out. Had to pass the locals for double quotes as escape characters. Hard to figure out the logic of when to use `=char(34)' vs. ustrunescape.

    Code:
    local      ldq    =  ustrunescape("\u201C")
    local      rdq    =  ustrunescape("\u201D")

    Comment

    Working...
    X