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!