Sorry!  It is the end of the day for me.

So

dput(x)

structure(list(prochi = c("CAO0000713", "CAO0000713", "CAO0000713",
"CAO0000713", "CAO0000713", "CAO0000713", "CAO0000713", "CAO0000713",
"CAO0000713", "CAO0000713"), prescribed_date = c("22/06/2001",
"28/04/2000", "10/04/2000", "03/07/2000", "09/01/2001", "16/10/2001",
"16/08/2001", "17/09/1993", "01/05/2001", "05/03/2001"), dataMonth =
c("NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL"), item_code = c("842752", "7800", "842652", "842652",
"842752", "842752", "842752", "39620", "842752", "842752"), res_seqno =
c("NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL"), quantity = c("60", "100G", "60", "60", "60", "60", "60",
"5ML", "60", "60"), directions = c("1/D", "A/TD", "1/D", "1/D",
"1/D", "1/D", "1/D", "NIL", "1/D", "1/D"), no_of_packs = c("NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
"NULL"), datasource = c("TSF", "TSF", "TSF", "TSF", "TSF", "TSF",
"TSF", "TSF", "TSF", "TSF"), scan_ref_no = c("NULL", "NULL",
"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"
)), .Names = c("prochi", "prescribed_date", "dataMonth", "item_code",
"res_seqno", "quantity", "directions", "no_of_packs", "datasource",
"scan_ref_no"), row.names = c(NA, 10L), class = "data.frame")


y_data <-
read.table(file="
http://n4.nabble.com/file/n1590804/feb09_267_presc_items_tsf.txt",
header = TRUE, sep = "|", quote = "\"'",

             dec = ".",as.is = TRUE,na.strings = "NA",colClasses = NA,
nrows = 3864284,
             skip = 0, check.names = TRUE,fill=TRUE,
             strip.white = TRUE, blank.lines.skip = TRUE,
             comment.char = "#", allowEscapes = FALSE, flush = FALSE,
             fileEncoding = "", encoding = "unknown")

So the y_data essentially contains the lookup table for the item codes in x.

require(sqldf)
z <- sqldf("select * from x left join y using (item_code)")
z

	[[alternative HTML version deleted]]

