{smcl}
{hline}
help for {cmd:stcmd}, {cmd:inputst} and {cmd:outputst}{right:(Roger Newson)}
{hline}


{title:Running the Stat/Transfer command from inside Stata}

{p 8 21 2}
{cmd:stcmd} [ {it:filetype1} ] {it:infilename}{cmd:.}{it:ext1} [ {it:filetype2} ] {it:outfilename}{cmd:.}{it:ext2} [ {it:switches} ]

{p 8 21 2}
{cmd:stcmd} {it:command_filename}{cmd:.stc}

{p 8 21 2}
{cmd:inputst} [ {it:filetype} ] {it:infilename}{cmd:.}{it:ext} [ {it:switches} ]

{p 8 21 2}
{cmd:outputst} [ {it:filetype} ] {it:outfilename}{cmd:.}{it:ext}  [ {it:switches} ]


{title:Description}

{pstd}
{cmd:stcmd} calls the Stat/Transfer command {cmd:st} to convert the data file {it:infilename.ext1} to
a new data file {it:outfilename.ext2}, or to obey the commands in the Stat/Transfer command file
{it:command_filename}{cmd:.stc}.
{cmd:inputst} inputs into the memory a Stata-converted version
of the data file {it:infilename.ext}, overwriting any existing dataset.
{cmd:outputst} outputs a converted version of the Stata dataset in memory to the data file {it:outfilename.ext}.
File types are determined by {it:filetype}, {it:filetype1} and/or {it:filetype2}, if present,
and by Stat/Transfer from the extensions {it:ext}, {it:ext1} and/or {it:ext2} otherwise.
File names containing spaces must be given in quotes.


{title:Switches for use with  {cmd:stcmd}, {cmd:inputst} and {cmd:outputst}}

{pstd}
These are prefixed by {cmd:/} under Windows and by {cmd:-} under Unix.
A list of these switches can be found in the Stat/Transfer manual for the user's installation.
The Windows switches for Version 9 of Stat/Transfer are as follows:

{p 4 8 2}
{cmd:/o-} specifies that Stat/Transfer will not optimize the output data set to be as small as possible
(as Stat/Transfer does by default).

{p 4 8 2}
{cmd:/oc} specifies that Stat/Transfer will optimize the output data set to be as small as possible,
and automatically drop constant or missing variables.

{p 4 8 2}
{cmd:/od} specifies that Stat/Transfer will optimize the output data set to be as small as possible,
but produce double precision variables where appropriate.

{p 4 8 2}
{cmd:/ocd} specifies that Stat/Transfer will optimize the output data set to be as small as possible,
and automatically drop constant or missing variables, but produce double precision variables where appropriate.

{p 4 8 2}
{cmd:/q} specifies that Stat/Transfer will execute quietly, producing no messages,
with the exception of error messages and warnings that a file is about to be overwritten.

{p 4 8 2}
{cmd:/r}[{it:page}{cmd:!}]{it:coor} specifies a worksheet range,
limited to page {it:page} and coordinates specified by {it:coor},
in an input worksheet.

{p 4 8 2}
{cmd:/s} will turn on messages and leave the Stat/Transfer window open until the return key is pressed.   

{p 4 8 2}
{cmd:/t}{it:tablename} is used in order to specify a table within a data source containing multiple tables.

{p 4 8 2}
{cmd:/v}{it:version_number} specifies that Stat/Transfer will write the output dataset
in the version of the appropriate format specified by the {it:version_number},
which should be a positive integer.
If this switch is not specified,
then Stat/Transfer writes the output dataset in the latest version of the appropriate format.

{p 4 8 2}
{cmd:/y} specifies that {it:outfilename}{cmd:.}{it:ext} will be overwritten, if it already exists.
(If {cmd:/y} is not specified, then Stat/Transfer consults the user before overwriting files.)


{title:Remarks}

{pstd}
{cmd:inputst} and {cmd:outputst} call {cmd:stcmd}, which in turn calls the Stat/Transfer {cmd:st} command.
For a list of file types and standard extensions used by Stat/Transfer,
see the Stat/Transfer manual or on-line help.

{pstd}
Stat/Transfer can be installed on Microsoft Windows, MacOS and some Unix platforms.
It is available from {browse "http://www.stata.com/":Stata Corporation}
and developed by {browse "http://www.stattransfer.com/":Circle Systems}.


{marker stcmd_technote}{...}
{title:Technical note}

{pstd}
The path for the Stat/Transfer {cmd:st} command varies from system to system.
{cmd:stcmd} assumes that this path is simply {cmd:st}, unless the {help macro:global macro}
{hi:StatTransfer_path} is evaluated, in which case {cmd:stcmd} assumes that the path is equal to the value of that macro.
Therefore, if the directory containing Stat/Transfer is on the user's default path,
then the user need not set a value for the {help macro:global macro} {hi:StatTransfer_path}.
Otherwise, the user should set a value for the {help macro:global macro} {hi:StatTransfer_path}.
This is probably done most easily by inserting a lines into the user's {help profile:profile do-file}
to initialize this {help macro:global macro} every time the user starts Stata.
For instance, under Windows, if the user's {help profile:profile do-file} contains the line

{p 8 12 2}{cmd:. global StatTransfer_path `"c:\Program Files\StatTransfer9\st.exe"'}{p_end}

{pstd}
and the {cmd:st} program of Stat/Transfer, in the user's system, has path {hi:"c:\Program Files\StatTransfer9\st.exe"},
then {cmd:stcmd} will find the {cmd:st} command of Stat/Transfer correctly on that path.

{pstd}
Note that, when the user upgrades to a new version of Stat/Transfer, the upgrade creates a new directory,
containing the new version of {hi:st.exe}.
Therefore, when Stat/Transfer is upgraded,
either the user's default directory search path should be altered,
or the line of code in the user's {help profile:profile do-file} setting the global macro {hi:StatTransfer_path} should be altered.


{title:Examples}

{p 8 12 2}{cmd:. inputst spss.sav}{p_end}

{p 8 12 2}{cmd:. outputst mydata.Rdata /y}{p_end}

{p 8 12 2}{cmd:. inputst mydata.Rdata /o-}{p_end}

{p 8 12 2}{cmd:. stcmd R mydata.Rdata hisdata.csv /y}{p_end}
{p 8 12 2}{cmd:. insheet using hisdata.csv, comma clear}{p_end}

{p 8 12 2}{cmd:. stcmd mystcom.stc}{p_end}


{title:Author}

{pstd}
Roger Newson, National Heart and Lung Institute, Imperial College London, UK.{break}
Email: {browse "mailto:r.newson@imperial.ac.uk":r.newson@imperial.ac.uk}


{title:Also see}

{p 4 13 2}
{bind: }Manual: {hi:[P] macro},
{hi:[GSW] A.7 Executing commands every time Stata is started},
{hi:[GSM] A.7 Executing commands every time Stata is started},
{hi:[GSU] A.7 Executing commands every time Stata is started}
{p_end}
{p 4 13 2}
On-line: help for {help macro}, {help profile}, {help profilew}, {help profilem}, {help profileu}
{p_end}
{p 4 13 2}
{bind:  }Other: {hi:Stat/Transfer .PDF Manual} if installed
{p_end}
