BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ewharry99
Calcite | Level 5
Hi How do I turn a name into last,first from 2 variables of firstnm lastnm?
1 ACCEPTED SOLUTION

Accepted Solutions
blakeellis18
Fluorite | Level 6

Hi!

if youre looking to make a new variable, say you name it "name" you would do

name= CATX (',', LastNm, FirstNm);

 

and if you wanted to get rid of those other two variables you would just drop them!

 

drop LastNm FirstNm;

View solution in original post

3 REPLIES 3
blakeellis18
Fluorite | Level 6

Hi!

if youre looking to make a new variable, say you name it "name" you would do

name= CATX (',', LastNm, FirstNm);

 

and if you wanted to get rid of those other two variables you would just drop them!

 

drop LastNm FirstNm;

Deanna_Payne
Obsidian | Level 7

Another option could be Cat

 

data Want;

set Have; 

FullName = cat(Lastnm, Firstnm);

run;

 

 

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=basess&docsetTarget=p1ka2...

Or Google: "Creating New Character Values in SAS Documentation" 

sdevenny
Calcite | Level 5

You could do this:

DATA new;
SET old;
FullName = LastNm || ',' || FirstNm;
RUN;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 448 views
  • 0 likes
  • 4 in conversation