+ Reply to Thread
Results 1 to 6 of 6

Thread: Contents of variable - Specify a value or an expression

  1. #1
    Points: 1,483, Level: 21
    Level completed: 83%, Points required for next Level: 17

    Location
    Denmark
    Posts
    77
    Thanks
    11
    Thanked 3 Times in 3 Posts

    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?

  2. #2
    RoboStataRaptor
    Points: 7,408, Level: 57
    Level completed: 29%, Points required for next Level: 142
    bukharin's Avatar
    Location
    Sydney, Australia
    Posts
    1,027
    Thanks
    9
    Thanked 243 Times in 236 Posts

    Re: Contents of variable - Specify a value or an expression

    It's just asking you for a default value for the new variable.

  3. #3
    Points: 1,483, Level: 21
    Level completed: 83%, Points required for next Level: 17

    Location
    Denmark
    Posts
    77
    Thanks
    11
    Thanked 3 Times in 3 Posts

    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?

  4. #4
    RoboStataRaptor
    Points: 7,408, Level: 57
    Level completed: 29%, Points required for next Level: 142
    bukharin's Avatar
    Location
    Sydney, Australia
    Posts
    1,027
    Thanks
    9
    Thanked 243 Times in 236 Posts

    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".

  5. #5
    Points: 1,483, Level: 21
    Level completed: 83%, Points required for next Level: 17

    Location
    Denmark
    Posts
    77
    Thanks
    11
    Thanked 3 Times in 3 Posts

    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.

  6. #6
    RoboStataRaptor
    Points: 7,408, Level: 57
    Level completed: 29%, Points required for next Level: 142
    bukharin's Avatar
    Location
    Sydney, Australia
    Posts
    1,027
    Thanks
    9
    Thanked 243 Times in 236 Posts

    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.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats