Welcome to Healthcare Magic
If you said you are unable to gain weight and anal itching it is possible you have pinworm infestation. Better to get stool tested for parasites. Pinworm can cause weight loss
, lack of sleep, swelling near anus. You could also be taking much acidic food like milk, paneer, the acidic food products can irritate the weak anus causing itching. Stay away from milk and milk products, citrus fruits for a while and see any improvement. You can try eating banana, jackfruit, chikoo, eggs, pulses, chicken if non-vegetarian to add to muscle protein. Do graded weight bearing exercises to improve physique. You should also get tested for TB which can cause weight loss, any swellings in body please report to Doctor also. Also get Haemoglobin
, blood counts tested as well.