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

Hi SAS Forum,

The  variable named “account_number” in dataset A is a numeric (it is sure).

I wanted to convert it into a character.

I used this code.

data B (rename=(account_number_new=account_number));

     set A;

     account_number_new=left(put(account_number, $32.));  /*to convert to character;*/

     drop account_number;

run;

Question:

This warning comes but conversion happened.

WARNING: Variable ACCOUNT_NUMBER has already been defined as numeric.

Could anyone help me to understand why this warning?

Thanks

Mirisage

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

Should be

account_number_new=left(put(account_number, 32.));  /*to convert to character;*/

View solution in original post

5 REPLIES 5
DBailey
Lapis Lazuli | Level 10

Should be

account_number_new=left(put(account_number, 32.));  /*to convert to character;*/

TashaChapman
Fluorite | Level 6

You're going to get the warning regardless, but you should be able to ignore it.  If your PROC Contents shows the variable you want coming out as character, you're doing fine.

Tom
Super User Tom
Super User

The warning message is because you tried to apply a character format ($32.) to a numeric variable.  Use a numeric format like 32. instead.

TashaChapman
Fluorite | Level 6

Duh! <smacks self on head> Tom is totally right.

You're using a character informat and applying it to a numeric variable.  The informat that you use in your PUT function should be the same variable type as the incoming source data (in this case numeric).  It will still output the new variable as character.

What I said was also technically kind of true, but that's just because SAS was being nice and forgiving, not because your code was technically correct. Smiley Happy

Mirisage
Obsidian | Level 7

Hi DBailey, Tom and Tasha,

Many thanks to eveyone of you for this help.

Regards

Mirisage

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 13030 views
  • 11 likes
  • 4 in conversation