BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
brownster
Calcite | Level 5

I am trying to convert all last names of a patient to the number 0. Writing out each last name is not realistic as I have over 2 million last names. Is there a way to do this? I am trying to recode names present to 0 and missing to 1. 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

If I am understanding you properly

 

newvariable = missing(last_name);
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

If I am understanding you properly

 

newvariable = missing(last_name);
--
Paige Miller
ballardw
Super User

If you want to do something like missing nonmissing you do not need to convert anything.

In a data step

 

MissingName = missing(yournamevariable);

 

will create a new variable named MissingName and if the variable is missing, i.e. blank, then will be assigned the value of 1 and 0 otherwise. Missing is one of the functions that works with both character and numeric variables.

 

If you want to overwrite the value in the name then you convert the result to text using the PUt function

 

name = put(missing(name),1. );

The format 1. means just use one character for the result so  the value will be in the first column of the name variable.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 417 views
  • 3 likes
  • 3 in conversation