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 |
Steve Samuels <sjsamuels@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Overwritten? |

Date |
Tue, 31 Dec 2013 13:43:16 -0500 |

Richard, I can't answer your question (2) because I know nothing about the panel problem you are trying to solve; I believe the answers to (1) and (3) are both "Yes". But my opinions don't count for much here, so find out for yourself. I used and taught SAS for over 30 years, but Stata displaced it in my personal work long ago. I originally found Stata much more enjoyable to use because it was interactive and fast. However I wasn't sure that it could handle the complicated data management tasks that SAS was famous for. As a test, I undertook to recreate with Stata a longitudinal data set from multiple source records, something I'd previously done in SAS. I succeeded and have never looked back. I think that you find Stata's syntax difficult because you started with complex problems and never learned the basics. Take some time to go through a couple of the great tutorials listed at http://www.stata.com/links/resources-for-learning-stata/. Steve On Dec 31, 2013, at 12:28 PM, Francis, Richard N wrote: Hi Steve, Thank you for the suggestion, that might just do the trick! Sergiy developed the work-around targeted the idea of using panel data with the -sroot- program, and did address the -residuals- issue. The -residuals- issue arose after I began developing some proficiency with the panel data work-around developed by Sergiy. So, if I understand what you are suggesting: 1) your code will eliminate the need for -srootfix- ; 2) your code will permit the use of panel data; and 3) your code will address the creation of the new -residuals- variable .... am I on the right track? I am most grateful for your help. FYI, I am a SAS user, so Stata is VERY foreign. I try to get a general sense of the code, but the syntax is pretty much out of my grasp. Thanks again! Rick Francis Associate Professor Department of Accounting College of Business Administration University of Texas at El Paso 500 W. University Avenue El Paso, TX 79968 Office: 915-747-7953 FAX: 915-747-8618 Email: rnfrancis@utep.edu -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Steve Samuels Sent: Tuesday, December 31, 2013 10:00 AM To: statalist@hsphsun2.harvard.edu Subject: Re: st: Overwritten? Your problem is easy to diagnose, I think: -sroot.ado contains a -predict residuals, res- command. This is equivalent to generating a new variable. At the second iteration, -predict- should fail because the data set already contains a variable named "res". If I am correct, the problem has nothing to do with the -if- error that Sergiy's -srootfix- is designed to work around. In such situations, I use a -keep if-, -append-, and -save, replace- approach. Below is the outline of a do file for you to fill in. You should be able to call -sroot- directly, as -srootfix- is no longer needed. **********CODE BEGINS**************** /* Create a data set to hold results */ clear save dhold, emptyok replace forval i = 1/`limit' { use yourdata, clear keep if id ==`i' /* Do something that generates variables */ append using dhold save dhold, replace } **************CODE ENDS************** Steve Steven J Samuels sjsamuels@gmail.com 18 Cantine's Island Saugerties NY 12477 USA tel: 845-246-0774 On Dec 30, 2013, at 9:28 PM, Francis, Richard N wrote: Nick, Thank you for your advice. In your experience, is there a reasonable expectation that the original author will alter the program? Rick -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Monday, December 30, 2013 7:06 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: Overwritten? <> Side details first: A convention suggested for Statalist is to use notation such as -foo- to flag names of commands, variables, etc. as used in Stata. That way, for example, the word replace is to be understood as just ordinary English but the word -replace- is easy to spot as something that could be typed in Stata. A convention is just that, but I like the Statalist convention, and have often commended it. The different convention you're introducing here of using -FOO instead does not strike me as a good one, if only for the reason that upper case is usually not idiomatic Stata, but that's a personal view. For the record, -sroot- here is from Stata Journal 9(3) 2009. The nub of the matter I think is this. The program -srootfix- by Sergiy Radyakin -preserve-s your original data, does some work and when it's done -restore-s the original data. Thus it's futile adding new variables to the dataset after -preserve-, as they will just disappear at the -restore-. The -restore- is not explicit in the code, but it's automatic given the -preserve-. The fact that -preserve- requires a -restore- for the fix you originally asked for is explicit in http://www.stata.com/statalist/archive/2013-11/msg00103.html Short of fixing a clone of -sroot- properly so that you don't need a work-around, or asking the original author to do that for you, it seems that you would need to -save- the dataset you create each time and then -append- them all. Fixing this properly is the better solution, as then your overall problem should yield to -statsby-. Nick njcoxstata@gmail.com On 30 December 2013 21:59, Francis, Richard N <rnfrancis@utep.edu> wrote: > Have an option within a called program -SROOTFIX which generates residuals for a regression command. > > However, the variable containing the residuals -RES is absent. > > The called program -SROOTFIX actually calls another program -SROOT. > > Separate execution of -SROOT retains the residuals variable -RES, which suggests that something within the -SROOTFIX pgm overwrites the residuals variable -RES. > > The master program is as follows: > > forval i = 1/`limit' { > display "Iteration of `i' of `limit" > replace which = "`: label (id) `i''" in `i' > srootfix fcf if id == `i' , residuals(res) > qui foreach v in Z14 Z24 Z34 Z4t Z3t Z2t Z1t { > replace `v' = r(`v') in `i' > } > } > > I have executed the program with the -replace command. > > However, the residuals variable -RES continues to be absent. > > The contents of -SROOTFIX are as follows: > > *! By Sergiy Radyakin, 2013 > *! Fixes problem of -if- modifier [suspected] not working in public (SJ) version of -sroot-. > ** See http://www.stata.com/statalist/archive/2013-11/msg00366.html > > program define srootfix > version 9.2 > syntax varname(ts) [if] [in] ,[*] > preserve > marksample touse > keep if `touse' > sroot `varlist' , `options' > end > > ** end of file ** > > Any ideas for the absence of the residuals variable -RES are greatly appreciated. * * 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: Overwritten?***From:*"Francis, Richard N" <rnfrancis@utep.edu>

**Re: st: Overwritten?***From:*Nick Cox <njcoxstata@gmail.com>

**RE: st: Overwritten?***From:*"Francis, Richard N" <rnfrancis@utep.edu>

**Re: st: Overwritten?***From:*Steve Samuels <sjsamuels@gmail.com>

**RE: st: Overwritten?***From:*"Francis, Richard N" <rnfrancis@utep.edu>

- Prev by Date:
**RE: st: Overwritten?** - Next by Date:
**st: Propensity score balancing property** - Previous by thread:
**RE: st: Overwritten?** - Next by thread:
**st: xtivreg2 with factor variables** - Index(es):