Bookmark and Share

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]

RE: AW: st: AW: Syntax forvalues in Stata 11 SE


From   Gauri Khanna <[email protected]>
To   Stata List <[email protected]>
Subject   RE: AW: st: AW: Syntax forvalues in Stata 11 SE
Date   Thu, 23 Sep 2010 13:49:11 +0000

Dear Neil, 

Thank you for your detailed response. 

I changed all the syntax from ' to ` and re-ran the whole do file in one go using -version 9.2 - and it worked. 

Then, I dropped -version 9.2 - and it worked. 

The problem:

1. I was running the code line by line since I was running this file for the first time in a higher version and wanted to see if everything ran smoothly. This is where the problem began. The tempfiles were not saving and so I tried to save them by changing the syntax. On doing this, the tempfiles were saving as -.dta- file and not as a temp file which you pointed out and which I did not realise until now. 

2. Second, I was running my do file in parts which is not really conducive when it comes to a do file with so various commands calling on tempfiles, and using -local- 

So thank you for your assistance and to Martin and Neil: I can now move on to the next of the remaining 10 do files. 

With regards, 

Gauri 

----------------------------------------
> From: [email protected]
> Date: Thu, 23 Sep 2010 13:19:18 +0000
> Subject: Re: AW: st: AW: Syntax forvalues in Stata 11 SE
> To: [email protected]
>
> Listen to Nick Cox's comment, as I don't understand why you have...
>
> On Thu, Sep 23, 2010 at 1:07 PM, Gauri Khanna  wrote:
>> *use `allsvys1', clear /*OLD CODE: STATA 9*/
>> use "'allsvys1'", clear
>
> There was no change in syntax between Stata 9 and 11 as to the use of
> single quotes when referring to tempfiles.
>
> What your new code is doing is saving a file in the current directory
> as 'allsvys1'.dta and NOT saving it as the tempfile you are declaring
> at the start of your do-file.
>
>>     foreach x of local names {
>>         if "`x'"=="lgsmkc" {
>>             display "`x'"
>>             gen row'j'=lgcigc
>>             local j='j'+1
>>         }
>>         if "`x'"=="midage" {
>>             display "`x'"
>>             gen row'j'=midage
>>             local j='j'+1
>>         }
>>         if "`x'"=="agesmkc" {
>>             display "`x'"
>>             gen row'j'=agecigc
>>             local j='j'+1
>>         }
>>         if "`x'"=="_cons" {
>>             display "`x'"
>>             gen row'j'=1
>>             continue, break
>>         }
>>     }
>
> All of the references to the local macro j in this are wrong they
> should be `j' and not 'j'
>
> I'd be inclined to go back to your original code, and try running
> under version control by a adding the line -version 9.0- at the top of
> your do-file, it should run fine.
>
> As per Martin's point, how are you running your do-file?
>
> Are you sending the whole thing from the do-file editor, typing -do
> mydo-, highlighting a section of your do-file and sending it to Stata
> to run (if so which parts).
>
> Neil
>
> --
> "One should as a rule, respect public opinion in so far as is
> necessary to avoid starvation and to keep out of prison, but anything
> that goes beyond this is voluntary submission to an unnecessary
> tyranny, and is likely to interfere with happiness in all kinds of
> ways..." - Bertrand Russell
>
> Email - [email protected]
> Website - http://slack.ser.man.ac.uk/
> Photos - http://www.flickr.com/photos/slackline/
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index