Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: reading a value from a file into a scalar

Subject   Re: st: reading a value from a file into a scalar
From   Roger Newson <>
Date   Thu, 06 Jun 2002 16:24:21 +0100
In-reply-to   <>

At 15:59 06/06/02 +0100, Chris Wallace wrote:
Dear statalisters,

I am using -ml- to maximize a multiple equation model.  One of the
steps in calculating the likelihood involves finding a particular
solution to a quartic.

I have written a function to do this in maple, and now want to use this
from within stata.  I am hoping to do this by calling maple from stata

. shell maple < maple_command_file

and writing the result from maple into a file, then reading that into
stata as I don't believe stata will accept a return value from shell.
Can I assign the contents of a file (which I know will be a single
number) to a scalar?  How?

I'd rather not mess about with reading the single value using -infile-,
bc then I'd have to -preserve-/-restore- my rather large dataset each
Chris's best solution probably involves the -file- command, which can read values from a file directly into a scalar. Type -help file-, which should give you the answer if your version of Stata 7 dates from mid-2000 or later. (-file- is not necessarily found in Stata 7 manuals, as the first sub-version of Stata 7 didn't contain it.)

I hope this helps.


Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605

Opinions expressed are those of the author, not the institution.

* For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index