CASEID/Unique ID Related

These are CASEID related SPECIAL statements that assign the caseid into the data, gets the assigned caseid from the data, or writes and updates a caseid in the data.  These also get unique ID’s from the quota files and writes it to the data.

Valid Subtypes

  • Assign_Caseid_From_Data
  • Assign_Next_Caseid
  • Get_Data_Case
  • Get_Unique_Master_Number
  • Get_Unique_Quota_Number
  • Write_or_Update_Case



This command sets the case ID to the data found in the columns specified for the case ID in the header statement (See Study Header Statement). No data location or width can be specified on the question label line.



The command assigns the case ID now, if it is not already assigned, rather than at the end of the interview, and places it in the data in the specified case ID field (see Study Header Statement). This is particularly useful should you want to give suspended interviews the proper start sequence number; otherwise, they would be assigned an ID after the interview is completed, perhaps many days later.

Using this may cause gaps in the ID sequence, if, for instance, an interview is terminated after the ID has been assigned. You should probably not have a condition on the SPECIAL,ASSIGN_NEXT_CASEID statement; you would want to do this always or never. No data location or width can be specified on the question label line, the data is saved in the case ID field, which has a width already determined or specified.


Shortform: SPC,GETCASE

The SPECIAL,GET_DATA_CASE gets a case for Survent to use, typically for cleaning or recoding in Survent. You can use FIELD, USE_PREVIOUS, VARIABLE, USE_PREVIOUS, and TEXT,USE_PREVIOUS questions to display the current data, then build new questions to key new data in. The program will continue to search for cases that meet the criteria of the IF condition on the SPECIAL,GET_DATA_CASE until there are no cases left with the condition. The program will search for cases one more time after it has reached the end of the data file.

The syntax for the SPECIAL,GET_DATA_CASE question type is:



Enter the case ID that you want.
!VARIABLE,,4,4 }


The SPECIAL,GET_DATA_CASE may be used in two different ways.

  • The first way is to retrieve cases by their particular case ID.
    • You would use this method if you know the case you want to get and don’t want the program to present you with some random case based on data criteria.
  • The second way is to use a conditional statement to get cases based on criteria in the data, such as whether you have questions that need to be edited or coded.

The syntax for the SPECIAL,GET_DATA_CASE question type to retrieve a caseid is :

!SPECIAL,GET_DATA_CASE,<suboption>,<variable with case ID to get>

Valid Suboptions

    • This suboption will continue with the questionnaire rather than leaving you at the “Return to Interview” prompt if it does not find a case.
    • Suboptions QUIT_NO_CASE and CONTINUE_WHEN_NO_CASE will get a SURVBLOW error if you try to get another case when you already have a case you are working on in the interview.
    • With the SPECIAL,GET_DATA_CASE,CONTINUE_WHEN_NO_CASE, by default, when a matching case is not found, Survent prints a message saying that no case was found.
      • By using dump switch “>DUMP Y2” you can turn the message off.
    • This suboption ignores the fact that the specified case is checked out and gets it anyway.
    • This lets you return cases that were checked out because interviewers/coders aborted with errors while the study was still live, and it lets you read records even if someone else is currently updating them.
    • If you make modifications while another person currently has the same record and is also making changes, only the last modifications are saved, so use carefully.
    • Shortform: SPC,GETCASE,QUIT
    • This is the default.
    • This suboption is like CONTINUE_WHEN_NO_CASE regarding when it handles a case that has not been found.
    • Like WRITE_AND_QUIT_WHEN_NO_CASE, it is different in that if you have a case you are working on and go to retrieve another case in the same interview, it will write the case in hand back to the data file and then go and retrieve the new case you asked for, and continue.
    • This is only used in very complex database update situations.
    • This suboption is like QUIT_WHEN_NO_CASE regarding when it handles a case that has not been found.
    • It is different in that if you have a case you are working on and go to retrieve another case in the same interview, it will write the case in hand back to the data file and then go and retrieve the new case you asked for, and quit out.
    • This is only used in very complex database update situations.



Which case ID would you like to get? Enter “NM” for No More.
!NUMERIC,ZERO_FILL,,1-999999,,NM }


... rest of coding questionnaire

The questionnaire header must have the same study code as the data file that needs to be coded.

It must also match in terms of case length and text start. Note the use of the QFFNAME option to write a questionnaire with a different name than the study being coded. You may run the “updating” questionnaire at the same time as the questionnaire that is being updated is running under the Survox Server.

The SPECIAL,GET_DATA_CASE needs the case ID that it will get to be the exact characters and width of the case ID in the file, which is why in the example the field used is a NUMERIC,Z statement which zero-fills the field.

The program will look for the next case with a case ID that has the exact characters of the question specified.

The program searches for the case in the data file. If a matching case ID is found, it is retrieved for review and modification. If not, it returns an error message and puts you back at the “Return to Interview” prompt. Once a case is found, the data you recorded your request for a case ID in is replaced with the data from the case found. If you wish to save data created prior to getting the new case, use the LOCAL SCRATCH area. Then retrieve the data after the case has been found. If you type ABORT or use SPECIAL,ABORT to abort the interview, the modifications are not saved.

If you have a large data file to update, you can use the NUMCASES=# option in the questionnaire header to build the data file with a case ID directory in it. Then, when you ask for a particular case, the program can go directly to that case rather than searching sequentially through the file from the beginning (which it otherwise will do).

Using SPECIAL,GET_DATA_CASE to get Cases Based on Data Criteria

Unlike other conditional statements, the conditional statement on an SPECIAL,GET_DATA_CASE applies to the prospective cases you want to get, rather than the conditions in the current interview. If a case is not found which matches the data criteria specified, an ERROR message is returned and you are returned to the “Return to Interview” prompt (if using the default SPECIAL,GET_DATA_CASE suboption).

This type of SPECIAL,GET_DATA_CASE is used to do automatic coding or editing of open ends. It searches the file sequentially for the next case that matches the data criteria. Survent will search around the END OF FILE back to where you last started your search before giving you the message that it has not found a case; therefore, you will usually want to use a marker in the file to tell it that you have already been there and edited the particular case.



1 Edited the questionnaire }

{ Q1: HIDE
Original Question 1
9 Other Response }


... rest of coding questionnaire

Do you want to mark this case as coded?
1 Yes
2 No }

The questionnaire uses the condition to find cases that have an “Other” response to question 1 and have yet to be coded or edited. All questions from the original questionnaire can be redisplayed and used for conditional statements once the case to edit has been found. You can have an option to pick which question to code, whether to code or edit open-ends, etc.

By specifying the case ID field you can get a particular case ID.

NOTE: It may be collected as a number but it has to be evaluated as a string.


Which case ID would you like? Enter “NM” for “No More”
!NUMERIC,ZERO_FILL,,1-999999,,NM }





These statements generate a sequential number from the quota file independent of the case id. You must specify a location where the data will be placed. This will allow you to get a unique value applied to every interview.

For instance, you might want every 100th interview that is started to do something.   If you use a quota to control this, you can end up with conflicts if two Survent processes ask for the quota value at the exact same time causing them to get the same value, even if you immediately increment the quota before or after that.  By using the !SPECIAL,GET_UNIQUE_MASTER_NUMBER or the !SPECIAL,GET_UNIQUE_QUOTA_NUMBER you can avoid a conflict of values.

It could also be used when you are only assigning case ids to completed interviews but saving other data, or when you are editing data or using CALL questionnaires where there are multiple data records generated per case id.

You can specify the length of the ID and the sequential number can be from a regular quota (GET_UNIQUE_QUOTA_NUMBER) or a master quota (GET_UNIQUE_MASTER_NUMBER).

The syntax for these question types is:






This example will get the next sequential number from the regular quota file for a length of 6.

The value is saved in the quota file and may be accessed using QUOTAMOD’s “OUT” option; the exported ASCII file will have a line that reads: “*unique_number=00051” or something similar. You can modify the value by changing it and taking the “*” off the front of the line similar to the way you treat times reported, and reading the file back in using the QUOTAMOD “IN” option.



This command immediately writes out or updates a case rather than waiting until the end of the questionnaire; this is often used to save terminate data without using the standard ‘go to the end’ type of termination. By default, If the case ID is set with a SPECIAL,ASSIGN_NEXT_CASEID or SPECIAL,ASSIGN_CASEID_FROM_DATA, you will get a case ID, otherwise you will get the ID of “NOTKNOWN”.

The syntax for the SPECIAL,WRITE_OR_UPDATE_CASE question type is:


Valid Suboptions

    • This will generate a new case with a new case id, if you want respondent data from the same household or interview written in separate cases.
  • NEW
    • Shortform: SPC,WRITECASE,NEW
    • This will write a new case or a second case with a duplicate case id.
    • This will create a new record or update the current one (for data backup in case of a system crash).

To write a single record, use !SPECIAL,WRITE_OR_UPDATE_CASE or !SPECIAL,WRITE_OR_UPDATE_CASE,NEW. This will not assign a case id unless one has already been specified using a SPECIAL,ASSIGN_NEXT_CASEID or SPECIAL,ASSIGN_CASEID_FROM_DATA statement. By default it assigns a case ID of “NOTKNOWNID”. This is useful if you wish to write partial cases for screener terminates so that they don’t use up a case id which would only be applied to completed cases.

To update or save partial data cases, use !SPECIAL,WRITE_OR_UPDATE_CASE,UPDATE.

If you specify a SPECIAL, WRITE_OR_UPDATE_CASE,UPDATE statement, and no case has been written yet, it will generate a newcase with a new ID (unless you have already assigned an ID using a SPECIAL,ASSIGN_NEXT_CASEID or SPECIAL, ASSIGN_CASEID_FROM_DATA statement. In this case, it uses that ID). Each subsequent SPECIAL,WRITE_CASE,UPDATE statement updates the record already written.

At the end of the interview, there will be another update. This guarantees only one record per case id. This would most likely be used to save sensitive data in the event of a system crash, blow error, or other problem. You should check for and remove partial cases because this will lead to cases for interviews that were not completed.

To write additional cases within the same questionnaire, each with a new case id, you would use SPECIAL, WRITE_OR_UPDATE_CASE,ASSIGN_NEW_ID. This will write new cases each time specified with the “next” case ID assigned. You could for instance, write a separate case with a separate case id for each household member. The standard SPECIAL,WRITE_OR_UPDATE_CASE statement will also write multiple cases, but each with the case ID of “NOTKNOWNID” or the same case ID.