STUDY OBJECTIVE: To analyse if socioeconomic characteristics in area of living affect the risk of myocardial infarction in a Swedish urban population, and to evaluate to what extent the contextual effect is confounded by the individual exposures. DESIGN: A population based case-referent study (SHEEP). SETTING: Cases (n=1631) were all incident first events of myocardial infarction during 1992-1994. The study base included all Swedish citizens aged 45-70 years, living in Stockholm metropolitan area during these years. The social context of all metropolitan parishes (n=89) was determined by routine statistics on 21 socioeconomic indicators. A factor analysis of the socioeconomic indicators resulted in three dimensions of socioeconomic deprivation, which were analysed separately as three different contextual exposures. MAIN RESULTS: The main characteristics of the extracted factors were; class structure, social exclusion and poverty. Among men, there were increased relative risks of similar magnitudes (1.28 to 1.33) in the more deprived areas according to all three dimensions of the socioeconomic context. However, when adjusting for individual exposures, the poverty factor had the strongest contextual impact. The contextual effects among women showed a different pattern. In comparison with women living the most affluent areas according to the class structure index, women in the rest of Stockholm metropolitan area had nearly 70% higher risk of myocardial infarction after adjustment for individual social exposures. CONCLUSIONS: The results suggest that the socioeconomic context in area of living increases the risk of myocardial infarction. The increased risk in only partially explained by individual social factors (the compositional effect).