BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hb123
Calcite | Level 5

hi good morning to all,

 

I am having one dataset name ds1 which having three variables:

 

original dataset:

data ds1;
input id          subject$      marks;

datalines;
       101          maths           78
       102          science         88
;
run;

 

new dataset:

 

data ds3;
set ds1;
sub_val=input(subject,7.);

run;

 

 

as my 2nd variable is a character type I'm trying it to convert into numeric data type but in output results sub_val observation missing but in properties data type it is showing numeric data type.

 

iam not aware how to resolve this problem set , kindly give some valuable solution regarding this problem. 

 

 regards

hemen boro


original dataset.PNGoutput results.PNGresult output in sas.PNG
1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

A w.d informat would allow you to read a string of DIGITS and convert it to a number. You're dealing with strings of letters and there can't be some generic logic to convert such a string into a number.

 

You can always create your own informat (using proc format with invalue) to do such a conversion.

 

If you read your log you'd see messages like:

NOTE: Invalid argument to function INPUT at line 25 column 10.
id=101 subject=maths marks=78 sub_val=. _ERROR_=1 _N_=1
NOTE: Invalid argument to function INPUT at line 25 column 10.
id=102 subject=science marks=88 sub_val=. _ERROR_=1 _N_=2
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to 
      missing values.

 

View solution in original post

2 REPLIES 2
Patrick
Opal | Level 21

A w.d informat would allow you to read a string of DIGITS and convert it to a number. You're dealing with strings of letters and there can't be some generic logic to convert such a string into a number.

 

You can always create your own informat (using proc format with invalue) to do such a conversion.

 

If you read your log you'd see messages like:

NOTE: Invalid argument to function INPUT at line 25 column 10.
id=101 subject=maths marks=78 sub_val=. _ERROR_=1 _N_=1
NOTE: Invalid argument to function INPUT at line 25 column 10.
id=102 subject=science marks=88 sub_val=. _ERROR_=1 _N_=2
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to 
      missing values.

 

hb123
Calcite | Level 5

hi patrick,

 

thanks  a lot for giving valuable help in this regards.

 

and wish u a happy belated new year ahead.

 

thanks

hemen boro

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
  • 2 replies
  • 1301 views
  • 1 like
  • 2 in conversation