Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: If command for the existence of a data value

From   <[email protected]>
To   <[email protected]>
Subject   st: If command for the existence of a data value
Date   Fri, 28 Apr 2006 15:25:12 +0300


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. 

Best regards,

Samu Kurri

This mail has been checked for viruses

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index