Thanks,
that was my problem.
Samu
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: 28. huhtikuuta 2006 15:49
To: [email protected]
Subject: st: RE: If command for the existence of a data value
You need to read
http://www.stata.com/support/faqs/lang/ifqualifier.html
As I understand it, you want to loop over a set
of datasets, somewhat irregularly numbered.
In this situation, using -if- is not a good way to do it.
If you install -fs- by
ssc inst fs
and then
cd c:\data
and then
fs data*.txt
You can then go
foreach f in `r(files)' {
insheet using `f'
...
}
If this is not the problem, please explain what is.
Nick
[email protected]
[email protected]
> how can I do a loop (or an if command) so that STATA goes to the next
> value and does required calculations and after that continues to the
> next value etc.
>
> The problem is that I tried while loop so that i=i+1. But because my
> values are from eg. 1, 5, 6, 7, 11, ... the loop stops because it
> can't find number 2.
>
> I tried it like
>
> local i=2
> while `i'<687. {
> insheet using "C:\Data\Data`i'.txt"
>
> if m==`i' & change !=.{
>
>
> , where m is the conrol variable and change the valuable the one of
> which the calculations are done. This does not work. Instead of saying
> "look from m value i" I want that Stata finds the first value of m
> that exists in data, and then finds the next existing value etc.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
This mail has been checked for viruses
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/