BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JibJam221
Obsidian | Level 7

Hi everyone, 

 

I am trying to use the UPCASE function to make values in column "Login" from lowercase to uppercase, pasting it into column "USERID. my issue is im gettting blanks in return. 

 

The layout of the Logins are 3 characters and 3 numbers, for example: aaa222, aaa333, aaa444, etc.

 

I would like these to be: AAA222, AAA333, AAA444, etc.

Here is my code:

 

data work.people;
set work.people;

Login=upcase(USERID);
run;

 

This is what my output looks like:SAS Question.JPG

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Your description does not match what your code does. Try swapping your columns around:

* Current; Login=upcase(USERID);
* Suggested; USERID=upcase(Login);

View solution in original post

3 REPLIES 3
ballardw
Super User

@JibJam221 wrote:

Hi everyone, 

 

I am trying to use the UPCASE function to make values in column "Login" from lowercase to uppercase, pasting it into column "USERID. my issue is im gettting blanks in return. 

 

The layout of the Logins are 3 characters and 3 numbers, for example: aaa222, aaa333, aaa444, etc.

 

I would like these to be: AAA222, AAA333, AAA444, etc.

Here is my code:

 

data work.people;
set work.people;

Login=upcase(USERID);
run;

 

This is what my output looks like:SAS Question.JPG

 


You have two problems. First, you are using UPCASE on a numeric variable, Userid, which is missing for all of the values your pictures shows. So you create an character value from a missing number  and default display for missing is a period, which does not have an uppercase version. Second that number would in no manner contain "aaa" and the AAA would have to come from somewhere else.

 

One suspects that you think Userid should have letters but for some reason it is numeric. Which means any "userid" that might have had letters somewhere has lost them when this version of the variable was created.

 

BTW the reason you see a dot so far from the left margin is when you convert numeric variables without explicit controls the likely default format used is best12 and will have the dot in the 12th character position from the left.

 

Did you read your log? I bet there is a Note about "numeric values have been converted to character" somewhere which would tell you if you haven't looked lately that Userid is numeric.

 

Habitual use of the construct

data work.people;
    set work.people;

with the same data set on set and Data statements will lead to problems if you make a logic mistake as using code this way completely replaces the source data. I suspect that may be what somewhat related to your missing Userid values.

ChrisHemedinger
Community Manager

According the to screenshot you included, USERID is a numeric variable. It can happen if you use a wrong variable name and the DATA step will make a variable with that spelling, numeric by default.

 

Are you certain that's the name of the variable you want to transform?

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
SASKiwi
PROC Star

Your description does not match what your code does. Try swapping your columns around:

* Current; Login=upcase(USERID);
* Suggested; USERID=upcase(Login);

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1652 views
  • 2 likes
  • 4 in conversation