Hi everyone,
I'm trying to mass-produce reports based on statistical output from using the putdocx command. Is there a way to use the putdocx command conditionally? The 'if' option is not allowed for putdocx (e.g. putdocx text ("[text]") if [condition]).
For example, I've tried the below:
However, the resulting .docx document shows only the text output of the first condition, "close to", regardless of the value of `mean'. So essentially it ignores the conditions I set up.
For example, if the `mean' is 70.1, the resulting sentence in the .docx file is always:
Although my intention is for the resulting text, if the mean is 70.1, to be:
Is there a way to program using putdocx conditionally?
Thank you for your help.
I'm trying to mass-produce reports based on statistical output from using the putdocx command. Is there a way to use the putdocx command conditionally? The 'if' option is not allowed for putdocx (e.g. putdocx text ("[text]") if [condition]).
For example, I've tried the below:
Code:
putdocx text ("Map X shows that the rate of `p' is ") sum rate if place=="`p'" return list local mean : display %4.1f `r(mean)' if `mean' >=49 | `mean' <=51 { putdocx text ("close to ") } else if `mean' <49 { putdocx text ("under ") } else if `mean' >51 { putdocx text ("above ") } putdocx text ("the national mean. ")
For example, if the `mean' is 70.1, the resulting sentence in the .docx file is always:
Map X shows that the rate of [place] is close to the national mean.
Map X shows that the rate of [place] is above the national mean.
Thank you for your help.
Comment