Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Jeph Herrin" <stata@spandrel.net> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: Identify computer on which Stata is running |
Date | Thu, 17 Oct 2013 09:36:52 -0400 |
There is a Stata macro functin -env- which returns environment variables. If your OS is Windows, you should be able to access the computer name via the environmental variable %COMPUTERNAME%. For other OSes, there should be something similar. hth, Jeph -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Chamara Anuranga Sent: Thursday, October 17, 2013 4:42 AM To: statalist@hsphsun2.harvard.edu Subject: Fwd: st: Identify computer on which Stata is running Dear Stefan, Following command may useful local folder: dir . dirs "*",respectcase foreach comname of local folder { dis "`comname'" cd "`comname'" } What you have to do is first change the directory to C:Users as it always in same path cd "C:\Users\" I think in this location you have only one folder which is the computer name. If you have more than one you have to use if condition. It may be possible as length of the computers name are 4 and last three are numbers. regards, Chamara On Thu, Oct 17, 2013 at 1:21 PM, Stefan Pichler <stefan__pichler@hotmail.com> wrote: > > Dear Statalisters, > > I am running Stata on different PC's. Is there a way that Stata knows from which PC it is running and changes the directory accordingly. To be more specific I would like to to the following: > > if currentPC==PC1 { > cd "C:\Users\a123" > } > if currentPC==PC2 { > cd "C:\Users\b456" > } > if currentPC==PC3 { > cd "C:\Users\c789" > } > ... > > > where Stata should find out which PC I am using and set the right directory. > > Any advice would be greatly appreciated. > > Stefan > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/