New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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