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