Hello,

I am dealing with fixed width data in a .txt file that includes date. The data spans 1973 to 2014 and is filed quarterly. The date on which the data was filed is included as a variable.

Code:
000148862STUCKEY,JAMES E,       19730930AA0011001000150-54 03GS0515-19 0301C008465810F1
000278418PALMER BETTY M          19730930AA0011001000130-34 07GS0710-14 0318C010471810F1
003141713SHAW MARY J                19730930AA0011001000135-39 04GS07UNSP  **** 009520815F1
Here you can see the filing date is in columns 33-40.

I am attemping to read .txt files beginning in the third quarter of 1973 through the last quarter of 2014, i.e., first the third and fourth quarters of 1973, then the first, second, and so on of 1974. I used this code:

Code:
forval year = 1973/2014{

    forval mth = 03(3)12{

        infix float id 1-9 str name 10-32 float filedate 33-40 str agency 41-44 ///
         str station 45-53 str age 54-59 str yearssincedegree 60-65 str educationlevel 66-67 ///
         str payplan 68-69 str grade 70-71 str los 72-77 str occupation 78-81 ///
         str occ_cat 82 str pay 83-88 str supervisory_status 89 str appointment 90-91 ///
         str schedule 92 str nsftp 93 using Status_Non_DoD_1973_12.txt, clear
         
        gen date2=date(string(filedate,"%8.0f"),"YMD")
        format date2 %td
        
        replace filedate = date2
        
        drop date2
        
        save Status_Non_DoD_`year'_`mth', replace
    }
}
I thought that this code would skip over the 03 and 06 values for 1973 because those files don't exist. However, it reads in the .txt file ending in 1973_09 and saves it as a file ending in 1973_03. I would like to know how to fix this.

Thank you.