Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Need to read a value in a stata table into a variable


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Need to read a value in a stata table into a variable
Date   Mon, 28 Jan 2013 21:32:30 +0000

This kind of posting will not evoke precise, useful replies.

1. When you say that you have a table, it appears that you are
referring to a dataset. When you talk about rows, you mean
observations. When you talk about local variables, you mean local
macros. I encourage you to use Stata terminology on Statalist.

2. You say that code you represent by multiple dots does not work and
elicits only the first observation. I can make a few wild guesses at
what you are doing, but this is not a puzzle list. Please show us the
exact code that is failing in your eyes.

3. You assert that you need to loop over observations "to perform
further analytics". We can have no idea what you mean precisely, but
that's likely to be quite wrong. The vast majority of Stata problems
do not involve explicit loops over observations.

My best advice is that you describe the problem you want to solve.

Nick


On Mon, Jan 28, 2013 at 9:02 PM, Subramanian, Hemang
<Hemang.Subramanian@scheller.gatech.edu> wrote:

>   I have a stata table in the following format:
>  <ac_code> <sale_date> id
>   1234    1Jan2003    1
>   1235    2Jan2005     2
>
>  Id is the unique identifier for each row. Is it possible to read the  values of ac_code and sale_date into a local variable say "code" and "sd".
>
>  I tried using foreach var in ac_code sale_date{...
> ....
> ...
> }
>  each time  this logic returns only the first row.. in the table.
>
>      I need to loop through the entire stata table of approximately 40000 rows, then  use the values stored in local variables "code" & "sd"  to perform further analytics on another larger .dta file (stata file).
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index