Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: Question About Evaluating Expressions

From   Erika Kociolek <>
Subject   st: Question About Evaluating Expressions
Date   Thu, 18 Apr 2013 07:03:45 -0700

I am trying to "bin" some data into categories using the code below. I
would like the bin_number variable to look like this:

condition     bin_number
905             900-910

If I run the code below, using condition = 905 as an example, I get
the following:
condition     bin_number
905             900-(900+10)

How do I get Stata to first evaluate what's in the parentheses and
then put the result into the bin_number variable?

generate bin_number = ""
local u 10

forvalues i = 900(`u')1500{
     replace bin_number = "`i'" + "-" + "(`i' + `u')" if (condition >
`i' & condition <= `i' + `u')

Any advice would be greatly appreciated.
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index