Contents of variable - Specify a value or an expression
Hey guys.
Can one of you explain this for me? I've just been playing around in the Data Editor and when I add a new variable, it tells me to specify a value or treat as missing. What exactly does this do?
Re: Contents of variable - Specify a value or an expression
But if the variable is, f.eks. is a "yes" or "no" question about the respondents use of hat (for example ), what value does that have? I'm thinking that a numeric value would be silly?
Re: Contents of variable - Specify a value or an expression
No, for a yes/no question a numeric value would be ideal: 0=no, 1=yes, . (missing)=don't know. This makes further analyses much easier. You can add a value label so that the 0/1 are displayed as no/yes, but they'll be considered numeric in statistical analyses - so you get the best of both worlds. Using numeric codes with value labels is generally the best way to handle categorical data in Stata.
Nevertheless if you really want to create a string variable from the Data Editor, all you need to do is enclose the string in quotes like "this".
Re: Contents of variable - Specify a value or an expression
Oh yeah, I get that. That's how the variable is coded when I do the answers, but the function I'm talking about only lets me apply a singe value to the entire variable. The variable could contain f.eks. 1,2,3 and 4 as numeric answers but the contents of variable only lets me apply a single name or number.
Re: Contents of variable - Specify a value or an expression
Yes, because it's an interface to -generate- so you need to specify one single value. See -help generate-. Of course, there are other ways to create a variable - see for example all the options in the "Data" menu.