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?

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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