Statalist


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

st: RE: programming loop local question


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   st: RE: programming loop local question
Date   Thu, 25 Jun 2009 06:53:48 +0800

...

If you display the -tw- line:
di "tw `list' (rcap higcs logcs m)"

You'll see that it will read:
tw e0 e1 e2 (rcap higcs logcs m)
which is not what you want (I think).

Why not try:
local e`r' ="(bar gcs m if `2'==`r') "
local list `list' `e`r''
______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2701
Fax: (08) 9224 8009
email: [email protected]
http://myprofile.cos.com/mccaul 
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
If you live to be one hundred, you've got it made.
Very few people die past that age - George Burns


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of moleps islon
Sent: Thursday, 25 June 2009 6:28 AM
To: [email protected]
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