Data editing > Changing the contents of a variable > Setting a random code in a column
 
Setting a random code in a column
Quick reference
To choose a random code from a list of codes, type:
data_var_name=rpunch('codes')
To choose a random code from the codes present in a column, type:
data_var_name=rpunch(col_number)
More information
Occasionally you might want to set a random code into a column, perhaps because the code in that column is incorrect. To do this, write:
cvar = rpunch('p')
cvar is the column into which one of the codes ā€˜pā€™ is to go. For example:
c115 = rpunch('1/5')
will place one of the codes 1 through 5 in column 115.
Alternatively, you can use rpunch with another C-variable, thus:
c115 = rpunch(c120)
Once this statement has been executed, column 115 will contain one of the codes present in column 120.
See also
Changing the contents of a variable