Statalist


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

Re: st: forvalues and _N


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   Re: st: forvalues and _N
Date   Fri, 10 Oct 2008 19:56:57 +0200

see -help _variables-. The equal sign evaluates this -expression- so no need for any -macro-...

HTH
Martin
_______________________
----- Original Message ----- From: "Michael I. Lichter" <[email protected]>
To: <[email protected]>
Sent: Friday, October 10, 2008 7:30 PM
Subject: Re: st: forvalues and _N


Whoa! This works even though `=_N' is clearly not a macro. Is this an undocumented feature, or is it a "real" part of Stata that will stick around? I'm sorry if this is discussed somewhere in the FAQ -- I have no idea how to search for it.

Michael

Philip Ryan wrote:
Try:

forvalues i = 1/`=_N'  {

....

}


Phil


At 06:01 PM 10/10/2008, you wrote:
Hi Stata users,

I have been searching for a special command in regard to *forvalues*, but without success.

I need something like:

gen N=_N

forvalues i = 1/N {
...
}

In my case, N is the maximum number of observations in my sample. I do not want to write 22345 or something instead of N because the number of observations might vary depending on how many observations I have dropped before.

But it is not possible to use N in a loop command at this place.


Are you aware of any stata updates being a solution to that problem?

Do you know a way to program it any better?

cheers

Bastian M Steingros


--
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx
*
*   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/

Philip Ryan
Professor,
Discipline of Public Health

Director, Data Management & Analysis Centre

Associate Dean (IT)
Faculty of Health Sciences

postal address:
Discipline of Public Health
Mail Drop DX650 511
University of Adelaide 5005
South Australia

location:
Level 6, Room 6-18
Bice Building
Royal Adelaide Hospital
North Terrace
Adelaide

tel +61 8 8303 3570
fax +61 8 8223 4075
http://www.public-health.adelaide.edu.au/
CRICOS Provider Number 00123M
-----------------------------------------------------------
This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright. If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.

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

--
Michael I. Lichter, Ph.D.
Research Assistant Professor & NRSA Fellow
UB Department of Family Medicine / Primary Care Research Institute
UB Clinical Center, 462 Grider Street, Buffalo, NY 14215
Office: CC 125 / Phone: 716-898-4751 / E-Mail: [email protected]
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index