Assign replicate numbers to an existing “raw” sample file

You can use the example below to read an existing “raw” ASCII sample file and add a replicate number to each record.


Read the comments at the top of the file and edit the >define statement to match what you want to do.

NOTE:This does NOT create “true” replicates in that each replicate should be a representative cross-section of the file as a whole. This procedure just splits the file into groups of equal size.

~CommentSpec file that will read a "raw" ASCII phone file and add a replicate number to each record.  You can set either the number of replicates you want or the number of phone numbers in each replicate.Name of ASCII input file>Define @Input   phone.rawName of ASCII output file>Define @Output  phone.repUse one of the two following defines to set up the reps. Do NOT USE BOTH!Use this define if you want to set how many replicates to set up'>Define @Number_of_Reps  12Use this define if you want to set up how many replicates will be in each rep>Define @Number_in_a_Rep 17Use this define if you want to start by randomly sorting the input so to make each replicate a random subset'>Define @Make_RandomChange this define if you do want to put the replicate number some place elseLINSUP: test8.6 /cfmc/jimr/examples/mentor% cat ass*.spx~CommentSpec file that will read a "raw" ASCII phone file and add a replicate number to each record.  You can set either the number of replicates you want or the number of phone numbers in each replicate.Name of ASCII input file>Define @Input   phone.rawName of ASCII output file>Define @Output  phone.repUse one of the two following defines to set up the reps. Do NOT USE BOTH!Use this define if you want to set how many replicates to set up'>Define @Number_of_Reps  12Use this define if you want to set up how many replicates will be in each rep>Define @Number_in_a_Rep 17Use this define if you want to start by randomly sorting the input so to make each replicate a random subset'>Define @Make_RandomChange this define if you do want to put the replicate number some place else other than the standard phone file position of 47.3>Define @RepLoc  47.3****************************************************************************************>AllowIndent>EchoDefines>IfDefine @Number_in_a_Rep>IfDefine @Number_of_Reps>Echo *********************************************>Echo YOU HAVE BOTH DEFINES SET, CAN'T RUN THAT WAY>Echo *********************************************~End>Endif>Endif>PurgeSame~Input @Input ASCII=5000>IfDefine @Make_Random~Output tempfile1 ASCII~Sort Random_Value~Input tempfile1 ASCII=5000>EndifNumbuf=2 Study=orig~Input $ Newbuf   Study=memory~Output tempfile2     ASCII~DefReplicate: [@RepLoc*Z]RepNum:    [!1.3]NumInRep:  [!5.5]Proc= MakeReplicates:>IfDefine @Number_of_RepsIf Memory![RepNum] < @Number_Of_RepsModify Memory![RepNum] += 1ElseModify Memory![RepNum] = 1EndifModify Replicate = Memory!RepNumWrite>Endif>IfDefine @Number_in_a_RepIf FirstCaseModify Memory!RepNum = 1EndifIf Memory!NumInRep < @Number_in_a_RepModify Memory!NumInRep += 1ElseModify Memory!RepNum += 1Modify Memory!NumInRep = 1EndifModify Replicate = Memory!RepNumWrite>Endif}~Exc Proc=MakeReplicates on Orig~Input tempfile2 ASCII=5000~Output @Output ASCII~Sort Replicate Random_Value>Ifdefine @Make_Random>Delete tempfile1>Endif>Delete tempfile2~End

  • assign_replicate_number.spx