How to create a .csv file

Why .csv

Comma separated variable or .csv files are simple text files that can be created or read using any spreadsheet, statistical, or text editing software (e.g. even NotePad or TextEdit!!). There's no reason why you need to use Excel to create this file, but that was the request:

  • Universal support
  • Human readable
  • Bullet proof

Open Excel

Open Excel (File… New) and create a new worksheet

Enter variable names

The first row must contain the variable names required for analysis. Order doesn't matter and extra columns will be ignored, but please pay attention to spelling and case

Enter dates of birth and visit

The date format for entering the date of birth (dob) and date of visit (dov) will depend on your version of Excel and how you have configured preferences/ languages:

Calculate the age in months

I will now calculate agemons (age in months) in cell F2. The WHO recommends a conversion factor of 30.4375 days per month. Since my Excel installation returns date differences in days, cell F2 will look like this:

  • = (E2-D2)/30.4375

Calculate the age in months

Alternatively, if you prefer age in calendar months

  • = DATEDIF(D2, E2, "m")

Repeat as needed

You can now enter additional rows. You may want to use the Fill Down function to extend the calculation in cell F2 to the new rows. Check the Help menu if you're unsure where to find it on your version of Excel: