TurtleDown
TurtleDown

Reputation: 15

Meaning of 3F7.1 in Fortran data format

I am trying to create an MDM file using HLM 7 Student version, but since I don't have access to SPSS I am trying to import my data using ASCII input. As part of this process I am required to input the data format Fortran style. Try as I might I have not been able to understand this step. Could someone familiar with Fortran (or even better HLM itself) explain to me how this works? Here is my current understanding

From the example EG3.DAT they give 

    (A4,1X,3F7.1)

I think

A4 signifies that the ID is 4 characters long.
1X means skip a space.
F.1 means that it should read 1 decimal places.

I am very confused about what 3F7 might mean.

EG3.DAT

2020   380.0   40.3   12.5
2040   502.0   83.1   18.6
2180   777.0   96.6   44.4

Below are examples from the help documents.

Rules for format statement Format statement example

EG1 data format EG2 data format EG3 data format

Upvotes: 1

Views: 583

Answers (3)

TurtleDown
TurtleDown

Reputation: 15

Procedure for making MDM file from excel for HLM:

-Make sure ALL the characters in ALL the columns line up

  • Select a column, then right click and select Format Cells
  • Then click on 'Custom' and go to the 'Type' box and enter the number of 0s you need to line everything up

-Remove all the tabs from the document and replace them with spaces.

  • Open the document in word and use find and replace

-To save the document as .dat

  • First save it as .txt

  • Then open it in Notepad and save it as .dat

To enter the data format (FORTRAN-Style)

The program wants to read the data file space by space, so you have to specify it perfectly so that it reads the whole set properly. If something is off, even by a single space, then your descriptive stats will be wonky compared to if you check them in another program.

  • Enclose the code with brackets ()
  • Divide the entries with commas ,

-Need ID column for all levels

  • ID column needs to be sorted so that it is in order from smallest to largest

  • Use A# with # being the number of characters in the ID

  • Use an X1 to move from the ID to the next column

-Need to say how many characters are needed in each column

  • Use F
  • After F is the number of characters needed for that column -Use F# (#= number)

  • There need to be enough character spaces to provide one 'gap' space between each column

  • There need to be enough to character spaces to allow for the decimal

  • As part of the F you need to specify the number of decimal places

  • You do this by adding a decimal point after the F number and then a number to represent the spaces you need -F#.#

  • You can use a number in front of the F so as to 'repeat' it. Not necessary though. -#F#.#

All in all, it should look something like this:

(A4,X1,F4.0,F5.1)

Helpful links:

https://books.google.de/books?id=VdmVtz6Wtc0C&pg=PA78&lpg=PA78&dq=data+format+fortran+style+hlm&source=bl&ots=kURJ6USN5e&sig=fdtsmTGSKFxn04wkxvRc2Vw1l5Q&hl=en&sa=X&ved=0ahUKEwi_yPurjYrYAhWIJuwKHa0uCuAQ6AEIPzAC#v=onepage&q&f=false http://www.ssicentral.com/hlm/help6/error/Problems_creating_MDM_files.pdf http://www.ssicentral.com/hlm/help7/faq/FAQ_Format_specifications_for_ASCII_data.pdf

Upvotes: 0

francescalus
francescalus

Reputation: 32366

In Fortran, so-called data edit descriptors (which format the input or output of data) may have repeat specifications.

In the format (A4,1X,3F7.1) the data edit descriptors are A4 and F7.1. Only F7.1 has a repeat specification (the number before the F). This simply means that the format is as though the descriptor appeared repeated: like F7.1, F7.1, F7.1. With a repeat specification of 1, or not given, there is just the single appearance.

The format of the question, then, is like

(A4,1X,F7.1,F7.1,F7.1)

This format is one that is covered by the rules provided in one of the images of the question. In particular, the aspect of repeat specification is given in rule 2 with the corresponding example of rule 3.

Further, in Fortran proper, a repeat count specifier may also be * as special case: that's like an exceptionally large repeat count. *(F7.1) would be like F7.1, F7.1, F7.1, .... I see no indication that this is supported by HLM but if this is needed a very large repeat count may be given instead.


In 1X the 1 isn't a repeat specification but an integral, and necessary, part of the position edit descriptor.

Upvotes: 0

One similar question is Explaining Fortran Write Format. Unfortunately it does not explicitly treat the F descriptor.

3F7.1 means 3 floating point numbers, each printed over 7 characters, each with one decimal number behind the decimal point. Leading characters are blanks.

For reading you don't need the .1 info at all, just read a floating point number from those 7 characters.

You guessed the meaning of A4 (string of four characters) and 1X (one blank) correctly.

Upvotes: 1

Related Questions