There's no particular reason your code shouldn't have worked, but in any event this is simpler:
data test;
length stringNumber $3;
input StringNumber $;
datalines;
25
270
;;;;
run;
data want;
set test;
number = input(stringNumber,3.);
put number=;
run;
The 3. is the length of the string, and you don't need to strip blanks off.
If this doesn't work, I would guess your 25 is not truly the number 25 plus a space, but instead has some non-space character (including NBSP, 'A0'x
, which is common on data grabbed from the web).
You can try:
data want;
set test;
number = input(compress(stringNumber,,'kd'),3.);
put number=;
run;
which will remove all non-digit characters from the string. If you're confident in your string having only numbers and spaces-of-some-form, then this should be safe; if it might contain other characters which might validly indicate a record you don't want (including things like "1.3" where this will return "13"), this could be risky without more detailed coding.