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:
Your description does not match what your code does. Try swapping your columns around:
* Current; Login=upcase(USERID);
* Suggested; USERID=upcase(Login);
@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:
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.
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?
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.