another question about 'input program'

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

another question about 'input program'

Bibel, Daniel (POL)

I appreciate the responses I have gotten to my question, but I must admit a failure (mine) to understand where to put my data file.

 

 

Question for you -- Where oh where does my "data list file =  'x:\testnibrsdata.dat'" go?  None of the examples I've found show where the 'data list' goes and it seems to me this must be specified!

The field ‘rdw’ indicate that the raw data is in one of two formats.

input program.
data list file =  'x:\testnibrsdata.dat' /  rdw 1-4.
do if rdw = 258.
file type mixed file = 'x:\ucrr\testnibrsdata.dat'
  record = ibr_rec 5 (a) .
Record type '1'.

<<data list statement here, same for record type 2,3,etc>>

 

End file type.

Else if rdw = 233.

File type mixed file = 'x:\ucrr\testnibrsdata.dat'
  record = ibr_rec 5 (a) .
Record type '1'.

<<data list statement here, same for record type 2,3,etc>>

 

End if.

End input program.


------------------------------------

When I run this syntax I get the following output:

input program. data list file= 'x:\testnibrsdata.dat' / 

rdw 1-4.

Data List will read 1 records from x:\testnibrsdata.dat

Variable          Rec   Start     End  Format

rdw                 1       1       4  F4.0

do if rdw = 258.

file type mixed file = 'x:\ucrr\testnibrsdata.dat'

>Error # 101.  Command name: file type >This command is not allowed in the set of file definition commands.  Either >complete the definition of the file, or use the NEW FILE command to discard

>the partial file definition.

>Execution of this command stops.  

record = ibr_rec 5 (a) . Record type '1'.

>Error # 6070.  Command name: Record type

>A RECORD TYPE command was found without a FILE TYPE command.  The RECORD TYPE >command can only be used inside a FILE TYPE structure. >Execution of this command stops.

 

 

 

 

Any suggestions would be greatly appreciated.

 

 

Daniel Bibel

Massachusetts State Police

Crime Reporting Unit

124 Acton Street

Maynard, MA 01754

978-451-3731 (voice)

978-451-3707 (fax)

 

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: another question about 'input program'

David Marso
Administrator
I believe I stated previously that you will have to go completely with INPUT PROGRAM.
FILE TYPE is *NOT* permitted in this case.
The filespec can be placed on the first DATA LIST
OTOH, consider the following where different 'levels' of the data reading control process reference different file names!  This reads a hierarchical file where the different levels of the hierarchy are stored in different files and the number of records in the next file to be read are stored in a field within the 'parent' record.
INPUT PROGRAM.
+  DATA LIST FILE 'C:\TEMP\data1.txt' /id reccount x1 to x4 (6F1).
+  LEAVE id reccount x1 to x4.
+  LOOP #=1 TO reccount.
+    DATA LIST FILE 'C:\TEMP\data2.txt' /ID2 level2_recnum reccount2 y1 TO y3 (6F1).
+    LEAVE ID2 level2_recnum reccount2 y1 TO y3.
+    LOOP ##=1 TO reccount2.
+      DATA LIST FILE 'C:\TEMP\data3.txt' /ID3 recnumlev_2 level3_recnum  fact (4F1).
+      END CASE.
+    END LOOP.
END LOOP.
END INPUT PROGRAM.
LIST.

<data1.txt>
143456
234567
323458

<data2.txt>
114789
123567
133567
144678
213567
223567
234678
313567
323567

<data3.txt>
1114
1125
1136
1143
1215
1226
1237
1319
1328
1330
1412
1427
1438
1445
2119
2129
2136
2219
2229
2236
2319
2329
2336
2349
3119
3126
3138
3219
3226
3283

This could also be read as follows using inline data see below  or the filespec could be placed on the first DATA LIST:
This could also be read using FILE TYPE NESTED, but I will leave that to you to think about.
INPUT PROGRAM.
+  DATA LIST  /id reccount x1 to x4 (6F1).
+  LEAVE id reccount x1 to x4.
+  LOOP #=1 TO reccount.
+    DATA LIST /ID2 level2_recnum reccount2 y1 TO y3 2-7.
+    LEAVE ID2 level2_recnum reccount2 y1 TO y3.
+    LOOP ##=1 TO reccount2.
+      DATA LIST  /ID3 recnumlev_2 level3_recnum  fact 3-6.
+      END CASE.
+    END LOOP.
END LOOP.
END INPUT PROGRAM.
BEGIN DATA
143456
 114789
  1114
  1125
  1136
  1143
 123567
  1215
  1226
  1237
 133567
  1319
  1328
  1330
 144678
  1412
  1427
  1438
  1445
234567
 213567
  1412
  1427
  1438
 223567
  2119
  2129
  2136
 234678
  2319
  2329
  2336
  2349
323458
 313567
  3119
  3126
  3138
 323567
  3219
  3226
  3283
END DATA.
LIST.




Bibel, Daniel (POL) wrote
I appreciate the responses I have gotten to my question, but I must admit a failure (mine) to understand where to put my data file.


Question for you -- Where oh where does my "data list file =  'x:\testnibrsdata.dat'" go?  None of the examples I've found show where the 'data list' goes and it seems to me this must be specified!

The field 'rdw' indicate that the raw data is in one of two formats.

input program.
data list file =  'x:\testnibrsdata.dat' /  rdw 1-4.
do if rdw = 258.
file type mixed file = 'x:\ucrr\testnibrsdata.dat'
  record = ibr_rec 5 (a) .
Record type '1'.
<<data list statement here, same for record type 2,3,etc>>

End file type.
Else if rdw = 233.
File type mixed file = 'x:\ucrr\testnibrsdata.dat'
  record = ibr_rec 5 (a) .
Record type '1'.
<<data list statement here, same for record type 2,3,etc>>

End if.
End input program.

------------------------------------
When I run this syntax I get the following output:
input program. data list file= 'x:\testnibrsdata.dat' /
rdw 1-4.
Data List will read 1 records from x:\testnibrsdata.dat
Variable          Rec   Start     End  Format
rdw                 1       1       4  F4.0
do if rdw = 258.
file type mixed file = 'x:\ucrr\testnibrsdata.dat'
>Error # 101.  Command name: file type >This command is not allowed in the set of file definition commands.  Either >complete the definition of the file, or use the NEW FILE command to discard
>the partial file definition.
>Execution of this command stops.
record = ibr_rec 5 (a) . Record type '1'.
>Error # 6070.  Command name: Record type
>A RECORD TYPE command was found without a FILE TYPE command.  The RECORD TYPE >command can only be used inside a FILE TYPE structure. >Execution of this command stops.




Any suggestions would be greatly appreciated.


Daniel Bibel
Massachusetts State Police
Crime Reporting Unit
124 Acton Street
Maynard, MA 01754
978-451-3731 (voice)
978-451-3707 (fax)


=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: another question about 'input program'

David Marso
Administrator
Correction to my posting:
In order to read that file with FILE TYPE NESTED one would have to add a record type variable to each row.
It would look like the following along with the corresponding FILE TYPE code.

FILE TYPE NESTED /rectype 1 (A).
RECORD TYPE "A".
DATA LIST / ID 2 (F) rcount2 3 (F) x1 TO x4 4-7 (F).
RECORD TYPE "B".
DATA LIST /ID2 level2_recnum reccount2 y1 TO y3 3-8.
RECORD TYPE "C".
DATA LIST  /ID3 recnumlev_2 level3_recnum  fact 4-7.
END FILE TYPE.

BEGIN DATA
A143456
B 114789
C  1114
C  1125
C  1136
C  1143
B 123567
C  1215
C  1226
C  1237
B 133567
C  1319
C  1328
C  1330
B 144678
C  1412
C  1427
C  1438
C  1445
A234567
B 213567
C  1412
C  1427
C  1438
B 223567
C  2119
C  2129
C  2136
B 234678
C  2319
C  2329
C  2336
C  2349
A323458
B 313567
C  3119
C  3126
C  3138
B 323567
C  3219
C  3226
C  3283
END DATA.
LIST.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"