Skip to content

Commit

Permalink
FIX: Example did not compile due to a missing file. Project now compi…
Browse files Browse the repository at this point in the history
…les. Updated help files. Fixed ssc conflict. Updated Setup, Update, and Uninstall features. Added GetStarted message.
  • Loading branch information
IsaacDodd committed Aug 2, 2017
1 parent aa4fc1d commit cfb90fd
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 33 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stata module to generate a publication-quality subject disposition flow diagram
Use the **_flowchart_** package in Stata to generate a publication-quality **Subject Disposition Flowchart Diagram** in LaTeX Format. This package gives Stata the ability to generate the necessary TikZ code to include in a LaTeX and produce the diagram as a PDF or any other format.
The final diagram will be similar in style to the ones used in the PRISMA Statement, CONSORT 2010 Statement, or STROBE Statement Reporting Guidelines, which are very commonly used within formal publications for systematic review, clinical trial, or cohort study research findings.

For an example of the package's output, please see [example1output.pdf](https://github.com/IsaacDodd/flowchart/blob/master/example1output.pdf "example1output.pdf") and the example code that produced it in [example1.do](https://github.com/IsaacDodd/flowchart/blob/master/example1.do "example1.do"). Here is a low-resolution screenshot of the PDF:
For an example of the package's output, please see [example1output.pdf](https://github.com/IsaacDodd/flowchart/blob/master/example1output.pdf "example1output.pdf") and the example code that produced it in [flowchart_example1.do](https://github.com/IsaacDodd/flowchart/blob/master/flowchart_example1.do "flowchart_example1.do"). Here is a low-resolution screenshot of the PDF:
![Example1Output](https://github.com/IsaacDodd/flowchart/blob/master/PreviousVersions/example1output.png "Example 1 Output")

The format follows closely the example of a [CONSORT-style flow diagram at TeXample](http://www.texample.net/tikz/examples/consort-flowchart/) which was written in PGF/TikZ by Morten Willert. The example code to generate the above diagram is incldued in the Ancillary Files installed with *flowchart*.
Expand All @@ -29,9 +29,9 @@ The format follows closely the example of a [CONSORT-style flow diagram at TeXam

## How to Use

After installation, type **help flowchart** for detailed instructions on how to get started. Study the files **example1.do** and **example2.do** for very carefully laid out examples of usage and a very detailed, thorough explanation of the format.
After installation, type **help flowchart** for detailed instructions on how to get started. Study the files **flowchart_example1.do** and **flowchart_example2.do** for very carefully laid out examples of usage and a very detailed, thorough explanation of the format.

The format for the code follows this typical example, which is available in **example2.do**:
The format for the code follows this typical example, which is available in **flowchart_example2.do**:

```stata
* INITIALIZE: Start a new datatool variable file.
Expand Down
Binary file modified example1output.pdf
Binary file not shown.
Binary file modified example2output.pdf
Binary file not shown.
21 changes: 19 additions & 2 deletions flowchart.ado
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ program define flowchart
display ""
display "Getting Started:"
display ""
display " If this is your first time running the flowchart package, type: " _newline
display " . flowchart setup" _newline
if("`1'" == "") {
display " If this is your first time running the flowchart package, type: " _newline
display " . flowchart setup" _newline
}
display `" To start a new flowchart, here is a general starting point: "'
display ""
display `" Start with the command '. flowchart init using <filename>.data'"'
Expand All @@ -50,6 +52,10 @@ program define flowchart
display ""
display `" The flowchart package's website is at: https://github.com/IsaacDodd/flowchart/"'
display ""
display "License:" _newline
display " GNU LGPL 2007 - By installing this program you agree to this license, available in full here:" _newline
display `" https://github.com/IsaacDodd/flowchart/blob/master/license.txt"'
display ""
display "Read this message again at anytime by typing 'flowchart getstarted'"
}
else if("`1'" == "help" | "`1'" == "help,") {
Expand Down Expand Up @@ -445,28 +451,39 @@ program define flowchart_setup
* Install an updated version of texdoc
display " (2/3) Installing/Updating 'texdoc'..."
display ""
* Install texdoc
capture ssc install texdoc, replace
if (_rc) {
display as error "Setup Error: Installation of dependency 'texdoc' could not be completed. Please check your internet connection and try again."
exit 499
}
* Install sjlatex
capture net install sjlatex, from(http://www.stata-journal.com/production)
if (_rc) {
display as error "Setup Error: Installation of dependency 'sjlatex' for dependency 'texdoc' could not be completed. Please check your internet connection and try again."
exit 499
}
else {
display "...Texdoc installed/updated successfully."
display ""
}
display " (3/3) Installing Ancillary Files for 'flowchart'..."
display ""
capture net get flowchart, from("https://raw.github.com/IsaacDodd/flowchart/master/")
if (_rc) {
display as error "Setup Error: Setup could not install Ancillary Files. Please connect to the internet and try again." _newline " (1) Check your current working directory to see if these ancillary files already exist. If so, there is no need to re-run setup." _newline " (2) Try running the following command:" _newline " . net get flowchart, from(https://raw.github.com/isaacdodd/flowchart/master/)" _newline " (3) You may also download these files directly from the following URL:" _newline " https://github.com/IsaacDodd/flowchart/releases"
exit 499
}
else {
display ""
display "...Ancillary files installed successfully in current working directory:"
pwd
display ""
}
display "|||||| Setup Complete"
display ""
display "__________________________________________"
display ""
if(_rc == 0) {
sleep 2000
flowchart getstarted // Print the get started message.
Expand Down
4 changes: 2 additions & 2 deletions flowchart.pkg
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
v 3
* Reference http://www.stata.com/manuals13/rnet.pdf
d FLOWCHART: Generates subject disposition flow diagram figures in LaTeX using PGF/TikZ to include in manuscripts
d
d Distribution-Date: 20170801
d Distribution-Date: 20170802
d
d Requires: Stata version 13 and texdoc
d
Expand All @@ -17,6 +16,7 @@ f flowchart_example1.do
f flowchart_example2.do
f manuscript.tex
f methods--figure-flowchart.data
f methods--figure-flowchart.tex
f methods--figure-flowchart.tikz
f example1output.pdf
f example2output.pdf
Expand Down
12 changes: 7 additions & 5 deletions flowchart.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ Diagram in LaTeX format, similar in style to the ones used in the CONSORT 2010 S
Reporting Guidelines. An example flowchart can be found here: http://www.texample.net/tikz/examples/consort-flowchart/ {p_end}

{phang}
To setup flowchart, type 'flowchart setup'. This will update the flowchart package and its main dependencies in
your system's ado filepath and also download flowchart's ancillary files into your current working directory.
After installing the package, to setup flowchart type 'flowchart setup'. This will update the flowchart
package and its main dependencies in your system's ado filepath and also download flowchart's ancillary
files into your current working directory.
Updates to the FLOWCHART package can be installed by using the 'flowchart setup, update' command
or are available here: https://github.com/IsaacDodd/flowchart/ {p_end}

Support is available at: https://github.com/IsaacDodd/flowchart/issues/new/
Please see the Ancillary Files for extensive examples with explanations of usage. {p_end}
Please see the Ancillary Files for extensive examples with explanations of usage:
flowchart_example1.do, flowchart_example2.do, and manuscript.tex {p_end}

{marker syntax}{...}
{title:Syntax}
Expand Down Expand Up @@ -275,8 +277,8 @@ Here is a list of known problems that can arise in using this program and their
version 13 and lower and was fixed by Stata Corp. starting with Stata version 14. This
occurs because Stata keeps track of which packages are installed, from where, and if
you originally installed flowchart from the Boston College SSC database (i.e., through
'ssc install flowchart', or did so through typing 'help flowchart', which chooses the
ssc package by default), so updating flowchart through running 'flowchart setup' likely
'ssc install flowchart', or did so through typing 'help flowchart', which may have chosen
the ssc package by default), so updating flowchart by running 'flowchart setup' likely
installed a second installation of flowchart -- in reality you only have 1 installation
of flowchart but there are 2 entries in Stata's internal database of installed package.
Expand Down
48 changes: 30 additions & 18 deletions flowchart_example1.do
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,20 @@
*
* DEPENDENCIES:
* After installing flowchart, be sure the following are in place:
* 1. texdoc - STATA Command
* 1. texdoc, sjlatex - STATA Packages
* Installation Instructions:
* In the STATA command-line, run the following 2 commands:
* ssc install texdoc, replace
* net install sjlatex, from(http://www.stata-journal.com/production)
* 2. figure.texdoc = Ancillary File
* In the STATA command-line, run the following command:
* flowchart setup
* This installs 2 dependencies: texdoc and its dependency, sjlatex
* 2. figure-flowchart.texdoc = Ancillary File
* Installation Instructions:
* In the STATA command-line, run the following command:
* net get flowchart, from(https://raw.github.com/IsaacDodd/flowchart/)
* This will install all of the Ancillary Files to your working directory.
* In the STATA command-line, when you ran the setup command, it also
* installed the Ancillary Files into your present working directory.
* 3. LaTeX Setup (Typesetting)
* A LaTeX setup should be installed to compile .tex and .tikz files:
* a) Distribution (MiKTeX or TeXLive)
* Recommended: MiKTeX, then use it to install the following packages:
* datatool, listings, multicols, xcolor, graphicx, tikz
* datatool, listings, multicol, xcolor, graphicx, tikz
* Download: https://miktex.org/download/
* b) Distribution Engine
* Recommended: pdfLaTeX
Expand Down Expand Up @@ -80,6 +79,7 @@
*
* /Manuscript/
* |
* |-- ##-[ProjectName]-[Main-Manuscript-File].tex <-- LaTeX Document
* |-- ##-[ProjectName]-[Section]-Fig-[FigureName].tex <-- LaTeX Document
* +-- ##-[ProjectName]-[Section]-Fig-[FigureName].tikz <-- TikZ Picture
*
Expand Down Expand Up @@ -120,25 +120,35 @@
* Do File
* This is the .do file that contains your analysis where you can use
* the flowchart commands to generate the diagram.
* See Example: example.do
* LaTeX Document
* See Example: flowchart_example2.do
* LaTeX Documents
* This is a (.tex) file that contains a \begin{figure}...\end{figure}
* Environment command. STATA does not manipulate this file. It instead
* contains all of the design elements that arrange the TikZ picture
* appropriately in the Manuscrupt and also loads the Subanalysis Data
* appropriately in the Manuscript and also loads the Subanalysis Data
* (.data) in the Data file for generating the different components of the
* TikZ picture's diagram (e.g., data for the boxes of a
* Subject Disposition Flowchart).
* See Example: methods--figure-flowchart.tex
* The manuscript's .tex file can then include this .tex file specific to
* the figure directly into the manuscript file with an \input{ } command:
* \input{methods--figure-flowchart.tex}
* See Example: manuscript.tex
* Figure Texdoc Do File - Do Not Edit
* This Do file is a 'Texdoc Do File' which is to say it is invoked by the
* texdoc command in STATA in the Main Analysis File that is producing the
* Subanalysis Data created from your analysis using your dataset.
* See Example: figure-flowchart.texdoc
* Subanalysis Data created from your analysis using your dataset. There's
* no need to edit this file beyond changing its filename to match your
* project's naming convention.
* See Example: figure-flowchart.texdoc (No Need to Edit)
* TikZ Picture (Automatically regenerated)
* This is a 'picture' that is used by the TikZ package in LaTeX to
* generate a diagram in LaTeX.
* See Example: methods--figure-flowchart.tikz
* generate a diagram in LaTeX. There's no need to edit this file beyond
* changing its filename to match your project's naming convention.
* Instead, in your LaTeX document, use the \input{<filename.tikz>} to
* make LaTeX automatically include it in the final document when
* compiling.
* See Example: methods--figure-flowchart.tikz (No Need to Edit)
* Subanalysis Data File (Automatically regenerated)
* The data for a figure is produced from a subanalysis and is assigned to
* variables. The Data file consists of variables with the generated data,
Expand All @@ -148,8 +158,10 @@
* the subanalysis. The variables with data produced by the subanalysis
* have to have a unique name and are given a name in the do file that
* produces the figure. Data from the Dataset used in an analysis can be
* used to generate the data for the diagram.
* See Example: methods--figure-flowchart.data
* used to generate the data for the diagram. There's no need to edit the
* file beyond changing its filename to match your project's naming
* convention.
* See Example: methods--figure-flowchart.data (No Need to Edit)
*
* OVERALL:
*
Expand Down
4 changes: 2 additions & 2 deletions manuscript.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% \renewcommand{\rmdefault}{ppl} % Font Changes - PPL = Palatino
% Layout Management
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{multicols}
\usepackage{multicol}
% Design
\usepackage{xcolor} % Design - Custom Colors
\usepackage{graphicx} % Design - Graphics Packages
Expand Down Expand Up @@ -38,7 +38,7 @@
% %% Methods
% \input{04-ProjectName-Methods.tex}
\end{multicols} % Temporarily interrupt multicols (and later restart it) to accommodate a figure.
\input{Methods--Figure-Flowchart.tex}
\input{methods--figure-flowchart.tex}
\begin{multicols}{2}
% %% Results
% \input{05-ProjectName-Results.tex}
Expand Down
16 changes: 16 additions & 0 deletions methods--figure-flowchart.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%% Flowchart Based on the CONSORT 2010 Statement Guidelines
% Adapted from Citation: Willert, Morten Vejs. (2010 July). A CONSORT-style flowchart of a randomized controlled trial, using the PGF/TikZ package. Retrieved from http://www.texample.net/media/tikz/examples/TEX/consort-flowchart.tex on July 23, 2017. License: Creative Commons attribution license.
% Datatool Implementation - Based on example code from - Citation: P., Michael. (2016 Aug 3.). How to read a Variable from a file in LATEX?. Tex.stackexchange.com. Retrieved from https://tex.stackexchange.com/a/322198/138871 on July 23, 2017.
\begin{figure}
\begin{center}
%% Load Subanalysis Data for Figure into \figvalue{} commands
\DTLloaddb[noheader, keys={subanakey,subanavalue}]{subanalysis-flowchart}{"methods--figure-flowchart.data"}
\newcommand{\figvalue}[1]{\DTLfetch{subanalysis-flowchart}{subanakey}{#1}{subanavalue}}
% Style - Setting the typeface to sans serif and the font size to small
% (the scope of this style is local to the environment)
\sffamily
\footnotesize
\input{methods--figure-flowchart.tikz}
\caption{Flowchart of the analytic sample of survey subjects data.} \label{fig:StudyFlowchart}
\end{center}
\end{figure}
2 changes: 1 addition & 1 deletion stata.toc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ d
d {bf:Installation}
d Type {bf: net install flowchart, from(https://raw.github.com/IsaacDodd/flowchart/issues/new/) }
d {bf:Dependencies}
d {bf:texdoc} - Install this by typing '. ssc install texdoc, replace' after installing flowchart.
d {bf:texdoc} - Install this by typing 'flowchart setup' after installing flowchart.
d The texdoc package (written by Ben Jann) is a dependency for the flowchart package which writes LaTeX-formatted files.
d
d {bf:License}
Expand Down

0 comments on commit cfb90fd

Please sign in to comment.