Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating and renaming variables

    Hi,

    This seems like a simple question but I'm fairly new to Stata and having trouble getting started because I don't understand why a fairly basic command isn't working.

    I'm using a dataset that I've downloaded as a csv file, and have imported to Stata 14.

    I want to start making new versions of the variables I'm using in my project, removing missing values and adding labels. There are no labels in the downloaded.csv file, but I have them in a separate Excel workbook to copy from. I'm only using a few of the variables so was going to do this manually.

    I'm typing the following code:

    tab v3
    gen SupOppRenew =.
    replace SupOppRenew = 1 if v3 ==1

    and getting the message:
    type mismatch
    r(109);

    I don't understand why - can anyone help?

    Thanks,
    Kiera


  • #2
    my guess is that the variable named v3 is a string variable; you can tell by using the -describe- command; please read the FAQ and present an example using -dataex- and CODE blocks

    added: if my guess is correct, you will want to use the -destring- command unless you want to leave as a string in which case you want to surround the 1 with double quote marks ("1")

    Comment

    Working...
    X