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!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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