Be angry, and do not sin; ponder in your own hearts on your beds, and be silent. Selah  Offer right sacrifices, and put your trust in the LORD. (ESV)
What does it mean to be angry and not sin? Actually, the Hebrew here implies more of a "being agitated." Dr. John MacArthur says, "In this context, the admonition means to tremble or shake in the fear of the Lord so as not to sin." So, the emphasis is more on avoiding sin and recognizing his holiness rather than a command to be angry or agitated.
How do you view sin and how do you view the Lord. It seems that our culture, even in the church, takes a very light view of our own sin. We feel that because we are under grace instead of being under Law that we do not need to be so concerned about sin. But, is that a Biblical way to think? In the New Testament, the Apostle Paul helps us with that concern:
 What shall we say then? Are we to continue in sin that grace may abound?  By no means! How can we who died to sin still live in it? (ESV)
Being angry, or agitated, or trembling with the purpose of avoiding sin is what David is talking about here in this Psalm. Avoid sin, offer right sacrifices, and put your trust in the Lord. The bottom line is that we should do whatever we can to avoid sin. God is a holy God. We should love him so much that sin will be as abhorrent to us as it is to him.
How do you view sin? Do you take it lightly? Or do you seek the Lord's help to avoid it at all costs. Be creative in your efforts to walk in purity. The Holy Spirit will help. Ask him.