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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.