I live in Chamberi district, I guess on the southern edge. On weekend nights in the summer, the walk from here to Sol is almost like one large, never-ending party. I go past the mini-cluster of nightlife around Fortuny/Shabay/The Causeway near Ruben Dario Metro, then head on through Alonso Martinez, Chueca, Plaza Santa Ana, and Huertas. In many of these streets, there are more people around at 3:00 in the morning then there are at 3:00 in the afternoon, and it feels like one large street festival. Also, I find Madrid to have one of the best street lighting systems in the world. Stay on the main streets where people are, stay in a group if possible, don't overindulge, and you should be perfectly OK.