BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Siennayun
Calcite | Level 5
How can I convert a numeric variable to the character type for variable "Cylinders".

I have tried to use put(Cylinders , 6.); But it doesn't work.





Original dataset as follows:



data carA;

set sashelp.cars;

keep MPG_City Cylinders Weight;

where Cylinders in (4,6,8);

run;
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20
A=put(Cylinders , 6.); 

is the correct syntax.

Of course, if you attempt to change the variable type, this will not work.

As you didn't supply any code or log, the help on offer is very limited.

 

View solution in original post

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16

Please try

 

new_cylinders=put(Cylinders , best.);
Thanks,
Jag
Siennayun
Calcite | Level 5
Hi, I've tried this. It doesn't work either.
andreas_lds
Jade | Level 19

@Siennayun wrote:
Hi, I've tried this. It doesn't work either.

The phrase "doesn't work" can mean anything, so it is impossible to suggest something helpful. Please explain what you got a result and why that does not meet your expectation.

ChrisNZ
Tourmaline | Level 20
A=put(Cylinders , 6.); 

is the correct syntax.

Of course, if you attempt to change the variable type, this will not work.

As you didn't supply any code or log, the help on offer is very limited.

 

Siennayun
Calcite | Level 5
*It works this time.*

*Really appreciate your help !*

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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