There is a column Customer name with first and last names together. not all the values have both first and/or last names. Want to know how many of them truly have both first and last names. They are separated by spaces.
You can use COUNTW()
Example:
data want;
set have;
Fullname=(COUNTW(name)>1);
run;
proc sql;
select "Full Names",sum(COUNTW(name)>1) as N
from have
;
quit;
only way is to check the length before and after compressing the name. if they are equal then either names is missing,
You can count the words in a name but you can't accurately check if they have both first and last name.
For example is Bruce Roger two first names or a first name and a last name? Either of these names could be a first name or a last name.
Another: Van Hurst - is this a first name and a last name or a two word last name?
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.