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

Hi - I'm trying to mess with some name variables in proc sql and the last step is to create the name in the format J. DOE. I can figure out how to keep the last name as lowercase (J. Doe) but not how to make the last upper case. Any suggestions?

 

I tried: upcase(last) as upcaselast in the create table, but that didn't work. Below is my code:

 

proc sql;
create table new as
Select first as firstname length=25,
last as lastname length=25,
strip(scan(first,1,' ') || " " || scan(last,1,' ')) as fullname length=51,
strip(substr(scan(first,1,' '),1,1) || ". " || scan(last,1,' ')) as filast length=28
from salaries;
quit;
proc print data=new;
var firstname lastname fullname filast;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You could use

 

upcase(strip(substr(scan(first,1,' '),1,1) || ". " || scan(last,1,' '))) as filast length=28
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You could use

 

upcase(strip(substr(scan(first,1,' '),1,1) || ". " || scan(last,1,' '))) as filast length=28
--
Paige Miller
hovicke
Calcite | Level 5
That should have been obvious... thanks!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 3554 views
  • 0 likes
  • 2 in conversation