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

st: Re: SAS libname equivalent


From   Roger Newson <[email protected]>
To   [email protected]
Subject   st: Re: SAS libname equivalent
Date   Wed, 28 Jan 2004 20:41:54 +0000

At 13:54 28/01/04 -0600, Jason A. Thompson wrote:
What is the correct way in Stata to establish pointers to paths in Windows XP, something along the lines of the LIBNAME and FILENAME statements in SAS? Can this be done using Windows environment variables? Can it be done without? Can it be done at all?! I've found the ability to do this in other environments critical to maintaining shared code.
I personally store the path in a macro using a command near the top of a do-file. For instance, I might have a line near the top of the do-file like

global retr1 "../../../data/retr1/dta"

which stores the path "../../../data/retr1/dta" in the global macro named retr1. If I want to refer to any Stata data file in that folder further down in the do-file, then I use a command like

use $retr1/request1,clear

which reads data from the file

../../../data/retr1/dta/request1.dta

into the memory. If you later rearrange your hierarchy of folders, then you need only alter the line near the top of the do-file with the -global- statement, and do not have to change any of the references further down. See -help macro- for more information about Stata macros.

I hope this helps.

Roger


--
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
Email: [email protected]
Website: http://www.kcl-phs.org.uk/rogernewson

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

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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