good day
is there any function can count the blank from name string
FACEBK AABMSW FBMEADS IRL |
like there are 3 blanks over the name string
i also do some data cleansing on this record and the result is FACEBKAAB
can i using that cleansing result and scan/crosscheck the original record and show below result?
because i did the compress on my cleaned record and i wanted to keep that blank in this attempt of crosscheck
FACEBK AAB
so that i can know how well is my cleansing.
thanks in advance
Harry
Character strings offer huge numbers of variations: trailing blanks (that should presumably not be counted), multiple blanks between words (that presumably should be counted) to name a few. I would try it differently:
data want;
set have;
n_blanks = lengthn(var) - lengthn(compress(var));
run;
data w;
str='FACEBK AABMSW FBMEADS IRL';
count=countc(str,' ');
run;
/*Or you could use S modifier in the same COUNTC function*/
data w;
str='FACEBK AABMSW FBMEADS IRL kjh';
count=countc(str,,'s');
run;
Character strings offer huge numbers of variations: trailing blanks (that should presumably not be counted), multiple blanks between words (that presumably should be counted) to name a few. I would try it differently:
data want;
set have;
n_blanks = lengthn(var) - lengthn(compress(var));
run;
thank you all for helping
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.