DATA Step, Macro, Functions and more

changing numeric to character

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

changing numeric to character

Hi, i have to change the type of variable from numeric to character. I've tried several ways, but i always get an error or warning Smiley Sad

 

Variable "x3" is in BEST8. format and SAS uses numeric format, but i need x3 variable to be in character format.

 

Dear communities, how to do it Smiley Very Happy


Accepted Solutions
Solution
2 weeks ago
PROC Star
Posts: 765

Re: changing numeric to character

You can not change the type of a variable once it is created. But you can convert a variable and assign it to a new variable like this

 

data test;
	format x3 best8.;
	x3=100.56;
	x3_char=put(x3, best8.);
run;

proc contents data=test;
run;

View solution in original post


All Replies
Solution
2 weeks ago
PROC Star
Posts: 765

Re: changing numeric to character

You can not change the type of a variable once it is created. But you can convert a variable and assign it to a new variable like this

 

data test;
	format x3 best8.;
	x3=100.56;
	x3_char=put(x3, best8.);
run;

proc contents data=test;
run;
New Contributor
Posts: 2

Re: changing numeric to character

Thanks Smiley Happy
PROC Star
Posts: 765

Re: changing numeric to character

Anytime, glad to help Smiley Happy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 91 views
  • 0 likes
  • 2 in conversation