- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OPEN (1,file="e:\\data\\testdef.txt",form='formatted',status='old',access='sequential')
OPE(2, file="e:\\data\\won05.testdef",access='sequential', form='unformatted', recordtype='fixed',status='replace',recl=410)
DO i=1,150000
READ (unit=1,fmt=2001,end=31) (var(j),j=1,480)
WRITE (2) (jint(var(j)),j=1,20),(iint(var(j)),j=21,30),(iint(var(j)),j=31,100),(var(j),j=101,270),(iint(var(j)),j=271,330),(var(j),j=331,480)
END DO
31 CLOSE (1)
CLOSE (2)
So the file "testdef.txt" is a text file created with STATA (and can be opened with a text editor as well) while the second file "won05.testdef" is the file with the correct format for the simulation model written in Fortran. The next step is make several simulations with the modelwhich result in an output file (simular to the file"won05.testdef"). The final step is to convert this file back to a file that can be handled with STATA again. Unfortunately, I was not able to complete this last step. Does anybody have usefull tips?
Gr. Henk-Wim
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That basically ignores any file structure, nor does not create any when writing it out.
So just use sequential READs and WRITEs to transfer in or out the raw data bytes.
That's what I use with MIDI files anyway, since they have a proprietary format.
When You're working with the STATA file you of course have to be cognizant about the
way the individual data items are represented, i.e little or big ENDIAN first, signed or unsigned, etc.
Another possibility is to open it with a DIRECT ACCESS qualifier, but that's a little more trouble when doing the I/O.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I already tried it with the STREAM keyword and unfortunately it did not work either. The same holds for opening the file with a DIRECT ACCESS qualifier. The problem is that the converted file is a binary file as well. I have added these files as attachments.
The first file (testdef.txt) is created with STATA and can be opened with text editors as well. The FORTRAN code posted in the threat converts this file into a binary file: won05.testdef. As a final step, I tried to convert the file back into STATA format. This file (testdef2.txt) is still binary, whereas I need this file to have the same format as the original file (testdef.txt). Any help?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page