BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8

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.

 

6 REPLIES 6
mohamed_zaki
Barite | Level 11

You can use COUNTW()

 

Example:

data want;
set have;
Fullname=(COUNTW(name)>1);
run;

 

mohamed_zaki
Barite | Level 11
proc sql;
select "Full Names",sum(COUNTW(name)>1) as N
from have
;
quit;
LinusH
Tourmaline | Level 20
"Truly" is a strong word. What locale do your names belong to?
Data never sleeps
SASPhile
Quartz | Level 8

only way is to check the length before and after compressing the name. if they are equal then either names is missing,

SASKiwi
PROC Star

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? 

LinusH
Tourmaline | Level 20
Yes that's what I was getting at.
You need a data quality tool like data flux to manage this.
Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 6 replies
  • 1640 views
  • 0 likes
  • 4 in conversation