Statalist The Stata Listserver


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

Re: st: String vector


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: String vector
Date   Mon, 30 Apr 2007 16:16:04 -0400

I'll tackle the first problem. When you build up the string in local groep and local sterfte you must enclose references to other locals in quotes.

Your code:

local groep="lft"+string((`y'-1)*5)+"_"+string(`y'*5)+`gesl';

will not work since +`gesl' at the end is expanded to +_m, and Stata doesn't know what _m is. Try

local groep="lft"+string((`y'-1)*5)+"_"+string(`y'*5)+"`gesl'";
local sterfte="stf"+"`gesl'";

although this last line can be just

local sterfte="stf`gesl'";

Michael Blasnik

----- Original Message ----- From: "Hendri Adriaens" <[email protected]>
To: <[email protected]>
Sent: Monday, April 30, 2007 3:57 PM
Subject: RE: st: String vector
<snip>

#delimit;
forvalues x=1/2 {;
 if `x'==1 local gesl="_m";
 if `x'==2 local gesl="_v";
 forvalues y=1/20 {;
   local groep="lft"+string((`y'-1)*5)+"_"+string(`y'*5)+`gesl';
   local sterfte="stf"+`gesl';
   replace `groep'=`groep'*(1-`sterfte'[`y']);
 };
};

(this doesn't show the need for the previous variable just yet, but I will
need it, so when loking at lft15_20_m, I need to have also lft10_25_m.) The
code above complains that _m is not found. I didn't expect that one...

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