Hi Everyone. I've a variable which has value like below. Here every part is seperated by / . Data have;
Input Mass $30.;
datalines;
abcde1234&9&Y / defgh0987&2&N / attire1790&&4&Y
Daikin1290&6&Y / rets0987&2&N / attire1790&4&Y
;
run; Required output;
Mass count1 count2
abcde1234&9&Y / defgh0987&2&N / attire1790&&4&Y 2 1
Daikin1290&6&Y / rets0987&2&N / attire1790&4&Y 3 0 I require the count of & and && followed by numeric in two different fields named count1, count2. For example : abcde1234&9&Y in this part the count1 is 1 and count2 is 0 ,because only one & is before 9 defgh0987&2&N in this part the count1 is 1 and count2 is 0 , because only one & is before 2. attire1790&&4&Y in this part the count1 is 0 and count2 is 1, because there are 2 &'s before 4. For your understanding purpose I differentiated them but it is a single value of Mass field. And also please do consider & and && 's count as 1 . For 1 & the count is 1 and for && the count is 1. Looking for some support. Thankyou!.
... View more