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]

st: RE: RE: RE: RE: Saving loop index value


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: RE: Saving loop index value
Date   Thu, 8 Apr 2010 21:50:52 +0200

<>

Actually, when I - set more 1- and -query output- subsequently, I get -set
more- as "off". When I - set more 2-, I get 


. query output
----------------------------------------------------------------------------
--------------------
    Output settings
        set more            2


but -set more- is "on". If you want to check this, clutter the screen with
cheap tricks such as 

***
set more 2

sysuse auto, clear
set tr on
hist price
***


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Hollis,Michael E
Sent: Donnerstag, 8. April 2010 21:45
To: [email protected]
Subject: st: RE: RE: RE: Saving loop index value

I guess I got lucky!  Stata seems to treat 1 as equivalent to "on" in
the -more- command.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Weiss
Sent: Thursday, April 08, 2010 12:38 PM
To: [email protected]
Subject: st: RE: RE: Saving loop index value


<>


BTW, Michael, where does the line -set more 1- come from? I never knew
it
was legal:


*******
set more 0
query output
set more 1
query output
set more 2
query output
*******


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Weiss
Sent: Donnerstag, 8. April 2010 21:22
To: [email protected]
Subject: st: RE: Saving loop index value


<>

You can -save- it with the dataset. -postfile-, btw, might be a smarter
choice for your problem.

*******
clear*
forv i=1/10{
set obs 1
gen byte myvar=`i'
save myfile`i', replace
drop _all
}

//example file # 7
u myfile7
l
*******


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Hollis,Michael E
Sent: Donnerstag, 8. April 2010 21:09
To: [email protected]
Subject: st: Saving loop index value

Greetings,

I want to "keep" the value of i which indexes the "forvalues" loop in
the loop below.  I've tried including it as a macro variable (i.e., `I')
on my keep statement.  I've also tried assigning it to a new variable
and then keeping the new variable.  Neither has worked.  Can someone
tell me how to keep i in my output dataset?

Thanks in advance.

P.S. I'm new to using macros and programming in Stata.



#delimit ;
   clear all;
   log using test.log, replace;
   set more 1;
   insheet using CAT_scenario_1.csv;          
   drop cat_scenario county;
   rename max_temp_degf maxt;
   rename precip_in prcp;
   forvalues i = 0/45 {;                       
	 preserve;
	 keep if offset==`i';
	 collapse (mean) prcp maxt, by(period);
	 do bm9304_6;
	 drop sdci_bp grup_bp;
	 keep year *_bp;
	 save scenario`i', replace;
	 restore;
     };

Michael Hollis, Ph.D
Resource and Analysis Group
Water Resource Management
Metropolitan Water District of Southern California
voice: 213-217-7228  fax: 213-2176119


*
*   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/

*
*   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/

*
*   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