BookmarkSubscribeRSS Feed
GeorgeSAS
Lapis Lazuli | Level 10

Hello,

why I can't convert the character m to numeric s?

 

data a;

m='12345678';

run;

data b;

set a;

s=put(m, $8.);

run;

 

Thanks

4 REPLIES 4
ballardw
Super User

PUT always creates a character variable used the way you did

 

Try

data b;

set a;

s= input(m, 8.);

run;

 

 

 

GeorgeSAS
Lapis Lazuli | Level 10

thank you, but s is still a char.

Reeza
Super User

It shouldn't be. Double check your code and output. Was your log clean? Is S already in your dataset, you can't change a variable type if it already exists in the dataset.

 

data a;
m='12345678';
run;
data b;
set a;
s=input(m, 8.);
run;

proc contents data=b;
run;

Alphabetic List of Variables and Attributes

#Variable Type Len

1m Char 8

2 s Num 8

GeorgeSAS
Lapis Lazuli | Level 10

I found the problem, the import excel file including special characters which make SAS function can't recginize that variable.

the special characters are something like ctrl+ enter in excel.

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!

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