Announcement

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

  • How can keep your multiple csv file stored in the do file so i can performance statistical analysis

    When I import each CSV file, I only have access to the last CSV file. Another thing I have an issue with is that all the datasets have a column called 'dates,' but each of them has different starting and ending dates.
    **
    clear
    set more off
    *#1 import the data
    import delimited "FLBPPRIV.csv", clear
    rename flbppriv fl_bp /* Units: Percentage; description (1939-01-01 to 2023-12-01): This series represents the total number of building permits for all structure types. Structure types include 1-unit, 2-unit, 3-unit, 4-unit, and 5-unit or more */

    rename date datestring
    gen datec = date(datestring, "YMD")
    gen date = mofd(datec)
    format date %tm
    tsset date



    import delimited "FLLFN.csv", clear
    rename fllfn fl_lf
    /* Units: Persons; Description: */

    rename date datestring
    gen datec = date(datestring, "YMD")
    gen date = mofd(datec)
    format date %tm
    tsset date



    import delimited "FLNAN.csv", clear
    rename flnan fl_nonfarm
    /* Units: Thousands of Persons; Description: the number of jobs in the private sector and government agencies. It excludes farm workers, private household employees, proprietors, non-profit employees, and actively serving military */

    rename date datestring
    gen datec = date(datestring, "YMD")
    gen date = mofd(datec)
    format date %tm
    tsset date



    import delimited "LNU02300000.csv", clear
    rename lnu02300000 us_epr
    * Renaming variable to simpler terms; Description:

    * 2d & 2e) Creating a new column called 'date' that show the year and month
    rename date datestring
    gen datec = date(datestring, "YMD")
    gen date = mofd(datec)
    format date %tm
    tsset date
    **

  • #2
    This looks a bit like homework. Here’s some hints. You don’t want to store data in your do file, that’s not good programming because it essentially hard codes the dataset into the file. Always import them from external files as you are doing now.

    Stata has supported frames for some time now which let you keep multiple datasets in memory. See -help frames- for an introduction. Load your data and then freely switch back and forth from your created frames as you please.

    Comment


    • #3
      Thank you, Leonardo! And yes, this is homework. I spent 3 whole days trying to figure this out. I'll let you know if I need more help.

      Comment

      Working...
      X