Statalist


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

st: Help with a loop


From   "Guillermo Villa" <[email protected]>
To   [email protected]
Subject   st: Help with a loop
Date   Mon, 16 Jul 2007 10:21:06 +0200

Dear statalisters,

I am working on a dataset that looks like this:

Var11 =09Var12=09Var13=09Var14=09Var15
1=092=093=09.=095
  =092=094=09.=09.
3=09.=094=09.=096
  =09.=09.=093=09.=09.

I would need to move all the values to the left, skipping the missing value=
s:

Var11 =09Var12=09Var13=09Var14=09Var15
1=092=093=095=09.
2=094=09.=09.=09.
3=094=096=09.=09.
3=09.=09.=09.=09.

I have tried the following:

foreach i of numlist 1/4 {
if Var1`i'=3D=3D. {
replace Var1`i'=3DVar1`i'+1
replace Var1`i'+1=3D=3D.
}
}

But I get this warning: + invalid name r(198), which refers to the
last replace command=85

Could you please help me? Do you think there is a more convenient way
of doing it?

Thanks.

Guillermo

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



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