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
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.
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.
hi patrick,
thanks a lot for giving valuable help in this regards.
and wish u a happy belated new year ahead.
thanks
hemen boro
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.
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.