I am trying to convert a text response containing monthly to a weekly value. The issue is when I run the code below it divides all values in var2 instead of just the ones that meet the text response requirements (e.g. 2 month) . Hopefully this makes sense, please let me know if my issue is unclear. data have; ID var1 var2 1 2 months 150 2 two months 90 3 1 week 30 4 1 week 45 5 2 months 100 6 2 months 220 Desired outcome= ID var1 var2 1 1 week 17.26 2 1 week 10.36 3 1 week 30 4 1 week 45 5 1 week 11.5 6 1 week 25.31 Current code data want; set have; if index(lowcase(var1), '2 month') > 0 then var2 = var2/8.69; else if index(lowcase(var1), '2 months') > 0 then var2 = var2/8.69; else if index(lowcase(var1), 'two months') > 0 then var2 = var2/8.69; run;
... View more