Announcement

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

  • Convert variable into data

    Hello,

    I have a variable called "BirthDate" which is in the following format: 199901 (which means, she was born in January of 1999). Anyone here knows how I can convert it to a data for the Stata understanding (1999m1?). I qant it in this way for then calculate the age of the individual.

    Many thanks!!

  • #2
    Well, you have told us with the variable BirthDate looks like to your eyes, but that leaves a mystery what it looks like to Stata--and it is the latter which matters for converting it. There are three possibilities, and I don't want to waste my time or yours posting code for all three scenarios, only one of which will work for you. So, please read the Forum FAQ for excellent advice about how to ask questions in way that maximize your chances of getting a timely and helpful response. Among the things you will learn about there is the use of the -dataex- command to show example data in a way that gives complete information. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X