Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Alan Neustadtl <[email protected]> |

To |
Statalist <[email protected]> |

Subject |
Re: st: Identify computer on which Stata is running |

Date |
Thu, 17 Oct 2013 15:13:30 -0400 |

```
On three computers I use the following:
capture cd C:\Users\user1\Documents\stata_project_home
capture cd C:\Users\user1\Documents\stata_project_office
capture cd C:\Users\user1\Documents\stata_project_laptop
Three computer, three different directories.
Best,
Alan
On Thu, Oct 17, 2013 at 2:58 PM, Glenn Hoetker <[email protected]> wrote:
> I've struggled with this too. My solution has been to use relative directories in my do files and set the working directory from the Stata command line before running them.
>
> That way, I can refer to ../data or ../graphs in my code and it will always end up in the right place.
>
> Won't work for everyone but it might be useful for some.
>
> Glenn Hoetker
> Arizona State University | W. P. Carey School of Business
> Dean's Council Distinguished Scholar & Associate Professor
> Affiliate Professor Sandra Day O'Conner College of Law
> Senior Sustainability Scholar Global Institute of Sustainability
> Faculty Fellow Center for Science, Law & Innovation
> [email protected] |http://hoetker.faculty.asu.edu | 480-965-4566
>
>
> On Oct 17, 2013, at 8:26 AM, "Chamara Anuranga" <[email protected]> wrote:
>
>> Hi,
>>
>> It may be useful to give example. There is way of access some system
>> and computer properties base on creturn command. such as
>> dis "`c(username)'"
>> dis "`c(machine_type)'"
>> dis "`c(os)'"
>>
>> These command also may helpful as Jeph pointed out. I have done a
>> program called expl (you can download using ssc install expl) with
>> help to create clickable link to open folders or files. I used loop
>> command to change the directory base on operation system.
>>
>> Chamara
>>
>> On Thu, Oct 17, 2013 at 7:06 PM, Jeph Herrin <[email protected]> wrote:
>>> 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: [email protected]
>>> [mailto:[email protected]] On Behalf Of Chamara Anuranga
>>> Sent: Thursday, October 17, 2013 4:42 AM
>>> To: [email protected]
>>> 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
>>> <[email protected]> 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/
>> *
>> * 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/
```

**References**:**st: Identify computer on which Stata is running***From:*Stefan Pichler <[email protected]>

**Fwd: st: Identify computer on which Stata is running***From:*Chamara Anuranga <[email protected]>

**RE: st: Identify computer on which Stata is running***From:*"Jeph Herrin" <[email protected]>

**Re: st: Identify computer on which Stata is running***From:*Chamara Anuranga <[email protected]>

**Re: st: Identify computer on which Stata is running***From:*Glenn Hoetker <[email protected]>

- Prev by Date:
**Re: st: Identify computer on which Stata is running** - Next by Date:
**Re: st: Stochastic frontier models to estimate multiple-output production functions** - Previous by thread:
**Re: st: Identify computer on which Stata is running** - Next by thread:
**st: How can I include exogenous variables into a VECM** - Index(es):