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: Use of matrix values in generate statements


From   [email protected] (William Gould, StataCorp LP)
To   [email protected]
Subject   Re: st: Use of matrix values in generate statements
Date   Mon, 28 Mar 2011 09:16:48 -0500

Daniel Feenberg <[email protected]> writes, 

> I am at the point of calculating the standard deduction for each taxpayer. 
> There are 6 possible filing status's and 24 years of tax law, so there are 
> 144 possible values for the deduction. [...
>
> the value for each taxpayer. As I understand it, Stata matricies can't be 
> used in -generate- statements, though, so I can't do something like:
> 
>     matrix input stdvalues (3700 6200...\3800 6350...\...
>     generate stded = stdvalues[year-1992,filestat]

Yes you can index into matrices in exactly the way Daniel showed, 
although Daniel shows incorrect syntax for -matrix input-.

In the example below, I assume there are 2 possible filing status's 
and 3 years of tax law:

        . list 

             +-------------------------+
             |    id   year   filestat |
             |-------------------------|
          1. | 10873   1993          1 |
          2. | 19223   1994          2 |
          3. | 21003   1995          1 |
             +-------------------------+

Note that in what follows, I code -generate stded- just as Daniel suggests, 

        . matrix input stdvalues = (3700, 6200 \ 3800, 6350 \ 3900, 7000)

        . generate stded = stdvalues[year-1992, filestat]

        . list

             +---------------------------------+
             |    id   year   filestat   stded |
             |---------------------------------|
          1. | 10873   1993          1    3700 |
          2. | 19223   1994          2    6350 |
          3. | 21003   1995          1    3900 |
             +---------------------------------+

-- Bill
[email protected]
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index