Announcement

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

  • Opening data-sets with a '.dat' file extension in Stata 13

    Hi, I'm using state-level data-sets [Youth Risk Behavioral Surveillance System (YRBSS) collected by the CDC] for my dissertation. Some of the earlier data-sets have '.dat' file extensions and I'm not sure how to open these or transform them into readable forms in Stata 13. I've been using StatTransfer to transfer all other YRBSS data-sets from SAS files into Stata, but the older data-sets with the '.dat' file extensions, I'm having trouble with. I contacted someone at the CDC, and he said I'd need to create a program for Stata to read these data-sets. Saying that, I'm wondering if there was an available paper or tutorial on how to do this?

    Any thoughts or ideas you may have would be greatly appreciated and thanks so much for your time.
    -Julie

  • #2
    Julie,

    I don't know anything about the YRBSS in particular, but based on the response you received from CDC, it sounds like the ,dat files are simply text files (as opposed to files in a particular software-specific format). You can check this by trying to read these file in a text editor (e.g., WordPad for Windows or similar) and see if the text contains readable characters. If so, then you need to find the documentation for the file(s) and use the Stata infile or infix commands to read them into memory. Let us know if you need more specific help with these commands.

    Regards,
    Joe

    Comment


    • #3
      Julie,

      According to the YRBSS website (http://www.cdc.gov/HealthyYouth/yrbs/data/), .dat files are indeed ASCII text files. You can download the User's Manual for each year, which will guide you in importing the file into Stata. Alternatively, if you have SAS available, you can use the SAS input program to read the data into SAS and then use StatTransfer to convert it to Stata.

      Regards,
      Joe

      Comment


      • #4
        If you have more time than money, you could use PSPP (the freeware version of SPSS, www.gnu.org/software/pspp) to read in the files and save them to SPSS (.sav) format with variable and value labels, then use Sergiy Radyakin's usespss (from SSC) to read in the SPSS file.

        David
        David Radwin
        Senior Researcher, California Competes
        californiacompetes.org
        Pronouns: He/Him

        Comment


        • #5
          Hi Julie,

          If you have stat transfer you can use the ASCII to Stata function. I recently did this with Bureau of Labor Statistics data.

          Comment


          • #6
            I am a Mac user and found a very simple solution: Change the extension from .dat to .txt, then run through StatTransfer as an ASCII/text file.

            To make the conversion, right click the file and select "get info." A box will pop up with info for the file. About 2/3 of the way down will be the name of the file. Delete the extension .dat and replace with .txt. Press "Enter" and Apple will ask if you want to use the new extension. Say "Yes" and you are on your way!

            Only issue is the file does not contain variable names. Instead, StatTransfer will input "Col1" through "Col###".

            Comment


            • #7
              This may help some YRBS users. I was having the same problem as Julie. I downloaded the Access file, read that into excel, saved it as a CSV, and read it into STATA with the column headings intact. This was a big time saver, instead of having to write a .do program.
              Happy analyzing, Michelle

              Comment


              • #8
                the -infix- command can handle .dat files if you need to specify the length of each variable, I think -import delimited- can too if your file has a delimiter.

                Comment

                Working...
                X