Statalist


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

st: Re: programming loop local question


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: Re: programming loop local question
Date   Thu, 25 Jun 2009 00:45:06 +0200

<>

Why do you want to -generate- a new variable which is supposed to hold a single string? And what is "p"? If it is a variable, as your -while- loop suggests, then Stata automatically picks the first observation to evaluate whether the -while- loop should run or not. I have a feeling that is not what you want...


HTH
Martin
_______________________
----- Original Message ----- From: "moleps islon" <[email protected]>
To: <[email protected]>
Sent: Thursday, June 25, 2009 12:28 AM
Subject: st: programming loop local question


I´m automating a bar graph program with ci and everything is working
out allright except for this loop and local variable that I cannot
figure out.
.....bunch of stuff first
local r=0

while p+1>`r'{
gen e`r'="(bar gcs m if `2'==`r') "

local list `list' e`r'
local r=`r'+1
}

tw `list' (rcap higcs logcs m)


and I get :

invalid 'e1'
r(198);



Error searching with a display of the local :

local r=0

while p+1>`r'{
di p
di `r'
gen e`r'="(bar gcs m if `2'==`r') "
di e`r'
local list `list' e`r'
di `list'
local r=`r'+1
}

tw `list' (rcap higcs logcs m)



2
0
(bar gcs m if maxaisorgansystemhead==0)
(bar gcs m if maxaisorgansystemhead==0)
2
1
(bar gcs m if maxaisorgansystemhead==1)
(bar gcs m if maxaisorgansystemhead==0) (bar gcs m if maxaisorgansystemhead==1)
2
2
(bar gcs m if maxaisorgansystemhead==2)
(bar gcs m if maxaisorgansystemhead==0) (bar gcs m if
maxaisorgansystemhead==1) (bar gcs m if maxaisorgansystemhead==2)
(bar gcs m if maxaisorgansystemhead==0) (bar gcs m if
maxaisorgansystemhead==1) (bar gcs m if maxaisorgansystemhead==2)
invalid 'e1'
r(198);


I´m sure there is a simple solution but I´ve trying with all sorts of
different " " ´` combinations without getting it to work and the last
display of the local seems to work so I really dont have a clue...

Regards,

Moleps

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