data newlib.c;
x='ABCDefghiJKLMNopqrs';
run;
data newlib.cw;
set newlib.c;
if count(x,lowcase(x)) then output;
run;
What is the question here?
Next code distinguish between upcase and lowcase letters.
Use the same method for counting:
data want;
x='ABCDefghiJKLMNopqrs';
do i =1 to length(x);
char = substr(x,i,1);
if char = upcase(char) then put CHAR ' is an upcase letter';
else put CHAR ' is a lowcase letter';
end;
run;
Do you need something like this:
data _null_;
x='ABC123ef';
/* k..() functions work with utf-8 */
l = klength(kcompress(x,,"kl"));
u = klength(kcompress(x,,"ku"));
put _all_;
run;
Bart
@BrahmanandaRao wrote:
I want count of lowcase and upcase in a string
Well, have you tried the suggested solution? If you have requirements for the output, show them. We can't read your mind 😉
In my code the variable L contains count of lower case letters, and the variable U contains count of upper case letters.
Bart
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.