BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have trying to convert id from text $37 to number 11. ,
I'm not sure why input function doesn't work in my case , any idea ?
Here's the code

----------------------------------
data table1;
set table0;
id= input(id,11.);
run;
---------------------------------------------------------------------------------------------------------------

Numeric values have been converted to character values at the places given by: (Line):(Column).
----------------------------------------------------------------------------------------------------------------
however I know that the " id" was character not numeric in table0

----------------------------------------------------------------------------------------------------------------
I also tried this code below , but it also doesn' t work.

data table1
set table0 ;
id= id*1;
run;
4 REPLIES 4
MHomes
Calcite | Level 5
Hi There,

The reason why it doesn't work is because the variable id (from the table0 dataset) is character and at compile time the PDV is set up with id being character. The first instance the compiler comes across the id variable is with the set statement.

So when you attempt to do the assignment statement the right hand side is a numeric value but the left hand side, the id variable, is defined as character - that is why you get the "NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column)."

What you need to do is create a new variable that is numeric and drop your character id variable from your data set. Below is some code that I hope helps.

data table1(drop=charId);
set table0(rename=(id=charId));
id=input(charId,11.);
run;

Cheers,
Michelle
deleted_user
Not applicable
Hi there,

Thank you for your fast reply , but I still get this error below
-------------------------------------------------------------------------------------------------------------
data table1(drop=charId);
set table0(rename=(id=charId));
ERROR: Variable id is not on file WORK.table1.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK.table1.
id=input(charId,11.);
run;



NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).

WARNING: The data set WORK.table1 may be incomplete. When this step was stopped there were 0 observations and 1 variables.
WARNING: Data set WORK.table1 was not replaced because this step was stopped.

Message was edited by: iamjeannie Message was edited by: iamjeannie
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Something about your SAS log does not make sense - suggest you reply to your post and paste the "entire SAS log".

Scott Barry
SBBWorks, Inc.
Cynthia_sas
SAS Super FREQ
Hi:
I agree with Scott. Something strange is happening. As you can see from my log, below, when I create TABLE0 with a character ID variable and then create TABLE1 using the rename/INPUT technique, I do not get the same error messages, so somehow, something is "off".
[pre]
92 data table0;
93 id = '12345678901';
94 numvar = 1234;
95 run;

NOTE: The data set WORK.TABLE0 has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


96
97
98
99 data table1(drop=charId);
100 set table0(rename=(id=charId));
101 id=input(charId,11.);
102 put _all_;
103 run;

charId=12345678901 numvar=1234 id=12345678901 _ERROR_=0 _N_=1
NOTE: There were 1 observations read from the data set WORK.TABLE0.
NOTE: The data set WORK.TABLE1 has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.01 seconds
[/pre]

In additions to Scott's suggestion, I'd recommend going back a bit farther to where TABLE0 is created and do a PROC CONTENTS on TABLE0 to make sure that all the variables in the dataset are in the form that you expect them to be.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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