Example of a move program to reformat data

The attached spec MOVEDATA.SPX is a move program to reformat data. It allows you to retain the original data locations and move data to locations that would otherwise overwrite existing data.

This is very useful approach for reformatting files received from clients which need to be reformatted into raw phone file format or for SURVENT data files that need to be reformatted into a specific format for a client. It is our experience that if you have to match an existing data layout on a complex questionnaire it is better to let SURVENT assign data positions and then write a reformat program to put the data where it belongs.

MOVEDATA.DAT is the name of the original file. Make sure you use the NUMBUF=2 option so you can have 2 files open at the same time.

Open a null file using the NEWBUF and STUDY options.

MOVEDATA.NEW is the name of the reformatted file. Make sure you set its length to the desired output length.

Use COPY commands to move data to the new postions from the original postions. Be sure to specify New! in front of all the receiving locations. However you cannot use Copy command if you are going to be moving data that was collected in Text questions. In that case you must use a Modify command.

The “NEW” data area is like a memory area and is not blanked when a new case is read in the “Original” file, so be sure to blank the entire NEW data area at the top of the procedure if there are any condition move/copy commands in the procedure.

Layout of original file

1-5 Market information

6-9 SIC code

10 1=User/2=Nonuser

11-20 Phone Number

21-50 Name

Layout of raw phone file

1-10 Phone Number

11-50 Blank

51-80 Name

81-85 Market information

86-89 SIC code

90 1=User/2=Non-user

>PURGESAME~In movedata.dat,ASCII=200,NumBuf=2,Study=Original~In $,Length=6000,NewBuf,Study=New~Out movedata.new,Length=250,ASCII~Def PROC=REFORM:If FirstCase ThenChoosefile "New"Next FirstChoosefile "Original"EndifBlank New![1-6000]     ''This command can be deleted, if none of the following''commands are conditional.Copy New![1.10]  =  [11.10]Copy New![51.30] =  [21.30]Copy New![81.10] =  [1.10]''The following is an example of the syntax to use if you were moving TEXT type''data from one file to the other''Modify New![99$T] = [75$T]Choosefile "New"WriteCase }~Exc Proc=Reform on Original~End

  • movedata.spx
  • movedata.dat