1. A data compression method for generating an initial value from sample data, registering in advance the initial value in a dictionary and encoding data using the dictionary, comprising: classifying character strings in sample data into groups with the same leading n characters (n=natural figure); and detecting a most frequently appearing character string from each of the groups and registering the most frequently appearing character string in the dictionary as an initial value.