A variable (in statistics) is a characteristic, attribute, or measurement that can have different "values".
Unlike the variables encountered in a basic algebra classes, the values of variables in a statistics class may be numbers, but they are not required to be. They can be categories as well.
Data are the values that a variable (or variables) actually assume.
Generally, a variable will describe the members of some population in some way.
Some examples of the types of variables encountered in statistics:
The values of some variables are more useful for comparison with one another than others. For example, if you have two fish whose lengths are 15 cm and 30 cm, you can say quite a few things:
Compare this with two movies that get ratings of 2 and 4 stars, respectively (out of a maximum of 5 stars).
The units of measurement in the first example was centimeters, while in the second, the units were stars on a 5 point scale. But clearly, there was a difference in the amount of information these measurements conveyed. As such, we classify variables according to the level or "'scale of measurement"' that was used:
A ratio level of measurement is one where "true ratios exist". That is to say, if you look at two things being measured and the first one has a measurement "x" times as big as the second, then the first thing truly is "x" times as big as the second thing.For example: Consider the two fish of lengths 15 cm and 30 cm. The ratio we are talking about here is 30/15 (which of course, equals 2/1). One number was twice as big as the other, so one fish was twice as long as the other.
A side effect of this ratio property is that "true zeros exist" as well. In other words, if something measures zero units, then that something doesn't have ANY of what you are measuring. For example: If the variable in question counts the number of hairs on a persons head, then a person with zero hairs on his head doesn't have ANY hair at all.
Compare this with measuring temperature (in degrees Fahrenheit or Celsius). Recall that temperature measures heat content. Does a room that measures 0 degrees have absolutely no heat? Certainly not! (Which is warmer: a room at zero degrees, or a room at -20 degrees?) Temperature in degrees Fahrenheit or Celsius also fails to admit "true ratios". A room that measures 50 degrees certainly doesn't have twice as much heat as a room that measures 25 degrees. Since we don't have true ratios or a true zero, temperature in degrees Fahrenheit or Celsius is not a ratio level of measurement. (On a side note, measuring temperature in degrees Kelvin is a ratio level of measurement.)
That said, knowing the temperature of two rooms does precisely define how much warmer one room is versus the other. Compare this with trying to figure precisely how much better a 4 out of 5 stars movie is compared to a 3 out of 5 stars movie.
When the differences between measurements is precisely defined, but we don't have true ratios or true zeros, we have an interval level of measurement. Temperature (in degrees Fahrenheit or Celsius, at least) is an example of this.
In other words, the interval between two measurements is precisely defined and can be easily compared with another such interval.
For example:
Consider three rooms with temperatures of 60 degrees, 40 degrees, and 30 degrees Celsius. While we can't say that the first room is twice as warm as the third (since the temperature doesn't give us true ratios), we can say that the difference between the first and the second (60 - 40) is twice as large as the difference between the second and the third (40 - 30).
In the first case, we have an interval between the two temperatures measuring 20 degrees. In the second case, we have an interval measuring 10 degrees. These intervals and differences are precisely-defined and can thus be compared with one another.
(At the risk of hurting some peoples' heads -- you may have noticed that the differences described above would have a ratio level of measurement, even though the original measurements have only an interval level of measurement!)
So under what scale of measurement do the movie ratings fall under?
We don't have true ratios, true zeros, or even precise differences between our measurements (number of stars, in this case). What we do have is an "ordering" of the movies by quality. We can say, when given two movies with different ratings, which one is a better movie (at least in the critic's eyes). When all that our measurements give us is a way to order (or rank) what we measured, then we have what is called an ordinal level of measurement.
Letter grades assigned to college courses are an example of an ordinal level of measurement. You know that a student that earns an A did better than one that earned a B, but you don't really know by how much. Were the grades really just one percent apart, and the second student had the misfortune to fall just below the cutoff for an A? Or did the B student really get lucky just to get the B, while the A student never missed a problem in the whole course? If all you have is the letter grade to look at, you can't tell. The differences between the performance different letter grades represent is not precisely defined.
So what about variables like gender or the model of a car? What scale of measurement are we using here? Clearly we don't have true ratios or true zeros, or precise differences between different values for our variable -- we don't even have numerical values! So it can't be a ratio level or interval level of measurement. Furthermore, despite what some male chauvinists would have you believe, there is no natural ordering of the sexes. So, we can't be talking about an ordinal level of measurement. In fact, the whole concept of "measuring" anything seems suspect here. We aren't really measuring anything -- we are categorizing. So if we are to talk about these types of variables in terms of a level of measurement, it is a level of measurement "in name only". In other words, we say these types of variables have a nominal level of measurement.
So, variables with a nominal level of measurement, really just categorize things. We should be clear about what we mean by that. The categories things are associated with by the "value" of the variable in question should be exhaustive (that means that everything fits into some category) and mutually exclusive (in other words, one thing is never in more than one category).
While we are on the subject of categories, I should mention that if a variable has either a nominal or ordinal level of measurement, it is called a categorical (or qualitative) variable, while if it has an interval or ratio level of measurement, it is called a numerical (or quantitative) variable.